PrimeFaces 3.0 - How can I set a TreeNode icon programmatically from backing bean?

旧时模样 提交于 2019-12-12 18:07:21

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!