[英]how to add image from java bean to <p:tree created dynamically?
to display <p: tree
I do : 显示
<p: tree
我做的<p: tree
:
<p:tree id="id" value="#{beanSession.rootAlpha}" var="node" selection="#{beanSession.selectedNode}" selectionMode="single"dynamic="true" cache="false">
<p:treeNode>
<h:outputText value="#{node}" />
</p:treeNode>
</p:tree>
in my java bean I used : 在我使用的Java bean中:
private TreeNode rootAlpha;
.... ....
output result : 输出结果:
>(not image here) A
> (image) ALLEMAGNE
>(image) BERLIN
>ALGERIA
> B
> C
...
I want to add an image (icon) on the childnode ex : ALLEMAGNE
and BERLIN
but not in the parent node ex ABC
... 我想在子节点ex上添加图像(图标):
ALLEMAGNE
和BERLIN
但不在父节点ex ABC
上添加图像(图标)...
the response is to add type as this : 响应是这样添加类型:
<p:tree id="id" value="#{beanSession.rootAlpha}" var="node" selection="#{beanSession.selectedNode}" selectionMode="single"dynamic="true" cache="false">
<p:treeNode>
<h:outputText value="#{node}" />
</p:treeNode>
<p:treeNode type="B">
<h:outputText value="#{node}" />
</p:treeNode>
<p:treeNode type="C">
<h:outputText value="#{node}" />
</p:treeNode>
</p:tree>
and in the java bean, we must add this type when we construct the tree : exmple with the seconde noode : // 2eme noeud 在Java bean中,构造树时必须添加此类型:例如,具有seconde noode:// 2eme noeud
DefaultTreeNode node2 = newDefaultTreeNode("B", "ALLEGMAGNE", node1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.