Hi All,
Is Tree2 & Checkbox working? (of so, could somebody provide a working
example; of both how the tree2 is used in the page and the code where
the node checking is done?)
It used to work but upon testing again, it appears that the "checked"
values are not passed anymore;
Some code: In my page I have:
<t:tree2 id="clientTree" value="#{calmgmtbean.treeRootNode}"
var="node" varNodeToggler="t" clientSideToggle="true"
preserveToggle="false" >
<f:facet name="root">
<h:panelGroup>
<h:outputLabel value="#{labels.calMgmt_tree_rootTxt}"
styleClass="inhoudKolom2"/>
</h:panelGroup>
</f:facet>
<f:facet name="calendarSet">
<h:panelGroup>
<t:graphicImage value="../pics/calMgmt/blue-folder-open.gif"
border="0" rendered="#{t.nodeExpanded}"/>
<t:graphicImage value="../pics/calMgmt/blue-folder-closed.png"
border="0" rendered="#{!t.nodeExpanded}"/>
<h:outputLabel value="#{labels.calMgmt_tree_calSetTxt} : #
{node.description}" styleClass="inhoudKolom2"/>
<h:outputText value=" (#{node.childCount})"
styleClass="childCount" rendered="#{!empty node.children}"/>
</h:panelGroup>
</f:facet>
<f:facet name="trigger">
<h:panelGroup>
<h:selectBooleanCheckbox value="#{node.checked}" />
<h:outputText value=" #{node.description} " style="font-size:
12px;font-style:italic;color:darkgrey;font-family:verdana;"/>
</h:panelGroup>
</f:facet>
</t:tree2>
<h:commandButton action="#{calmgmtbean.processNodes}" value="#
{labels.calMgmt_processNodes}"
title="#{labels.calMgmt_procesNodesTitle}" style="width:
6cm;"/>
& The code processing the nodes is:
public void handleLeafs(TreeNodeBase node){
if(selectedNodesIDs == null)selectedNodesIDs= new
ArrayList<String>();
logger.info("Handling of the selected Nodes starts now...");
if(node.isLeaf()){
logger.info("Node is a Leaf");
if(((TreeNodeChecked)node).isChecked()==true){
getSelectedNodesIDs().add(node.getIdentifier());
logger.info("Node met deze ID was gecheckt: "+ node.getIdentifier
());
}
}
// normal case: if node has kids --> we recursively get to the
Leafs to check them out:
else if(node.getChildCount() >0){
logger.info("Node has kids which we will start treating
now...");
List<TreeNodeBase> childs =
(List<TreeNodeBase>)node.getChildren();
for (TreeNodeBase nodeSub : childs) {
if(nodeSub.isLeaf()){
logger.info("Node is Leaf - is it
checked?");
// it is a leaf now, --> it is a
TreeNodeCheked
if(((TreeNodeChecked)nodeSub).isChecked()){
getSelectedNodesIDs().add(nodeSub.getIdentifier());
logger.info("Node met deze ID was gecheckt: "+
node.getIdentifier());
} else {logger.info("Node was not
checked");}
}
else {handleLeafs(nodeSub);}
}
}
else {logger.info("Node at this level has no kids... ");}
}
I had a look in the Tomahawk examples, but there is nog example ith
CheckBox...
Should I perhaps NOT take h:selectBooleanCheckbox but one of the
t:checkbox/t:selectBooleanCheckbox/... ?
The reason I stated "it appears that the "checked" values are not
passed anymore" is by looking at the log. I am of course 100% sure I
did check a Node but the logging reveals me this:
Node has kids which we will start treating now...
2006-09-09 18:21:33,395 INFO - Handling of the selected Nodes starts
now...
2006-09-09 18:21:33,395 INFO - Node has kids which we will start
treating now...
2006-09-09 18:21:33,396 INFO - Node is Leaf - is it checked?
2006-09-09 18:21:33,396 INFO - Node was not checked
2006-09-09 18:21:33,417 INFO - Handling of the selected Nodes
starts now...
2006-09-09 18:21:33,417 INFO - Node has kids which we will start
treating now...
2006-09-09 18:21:33,417 INFO - Node is Leaf - is it checked?
2006-09-09 18:21:33,417 INFO - Node was not checked
(= in a tree with 2 folders, each containing one event, algoritme =
breath first)