问题
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.
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.
Does anyone know how to do this?
I'm using the PrimeFaces 3.0-M2-SNAPSHOT.
回答1:
You can just use EL in the icon
attribute.
E.g.
<p:treeNode icon="#{item.icon}">
or, more generic (the #{item.type}
can return e.g. document
, image
, etc)
<p:treeNode icon="ui-icon ui-icon-#{item.type}">
来源:https://stackoverflow.com/questions/6347161/primefaces-3-0-how-can-i-set-a-treenode-icon-programmatically-from-backing-bea