PrimeFaces 3.0-如何从支持bean中以编程方式设置TreeNode图标? [英] PrimeFaces 3.0 - How can I set a TreeNode icon programmatically from backing bean?

查看:114
本文介绍了PrimeFaces 3.0-如何从支持bean中以编程方式设置TreeNode图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用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}可以返回例如documentimage等)

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆