PrimeFaces 3.0-如何从支持bean中以编程方式设置TreeNode图标? [英] PrimeFaces 3.0 - How can I set a TreeNode icon programmatically from backing bean?
问题描述
我正在尝试使用PrimeFaces <p:tree>
组件创建树视图.我从PrimeFaces 3.0 Showcase复制了示例代码,并且有一个简单的树视图,显示了非常简单的静态内容,该内容在支持bean上以编程方式声明了.
I am trying to create a treeview using the PrimeFaces <p:tree>
component. I copied the sample code from the PrimeFaces 3.0 Showcase and I have a simple treeview displaying very simple static content that is declared programmatically on the backing bean.
其中一个展示示例展示了如何在Facelet代码中为<p:treeNode>
分配图标(JQueryUI类型).对于展示柜来说,这很不错,但是如何通过后备bean代码中关联的TreeNode
分配图标呢?我没有在Javadocs中看到任何getter/setter/method.
One of the showcase examples shows how you can assign icons (the JQueryUI type) to a <p:treeNode>
in the Facelet code. That's nice eye-candy for the showcase, but how can I assign the icon via the associated TreeNode
in the backing bean code? I don't see any getter/setter/method listed in the Javadocs.
有人知道该怎么做吗?
我正在使用PrimeFaces 3.0-M2-SNAPSHOT.
I'm using the PrimeFaces 3.0-M2-SNAPSHOT.
推荐答案
您只需在icon
属性中使用EL.
You can just use EL in the icon
attribute.
例如
<p:treeNode icon="#{item.icon}">
或更通用(#{item.type}
可以返回例如document
,image
等)
or, more generic (the #{item.type}
can return e.g. document
, image
, etc)
<p:treeNode icon="ui-icon ui-icon-#{item.type}">
这篇关于PrimeFaces 3.0-如何从支持bean中以编程方式设置TreeNode图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!