Phil-
I used it this way:
JSP:
...
<t:tree2 id="tree" value="#{tree.tree}" clientSideToggle="true"
varNodeToggler="t" var="node">
<f:facet name="analysisFolder">
<h:panelGroup>
<h:selectBooleanCheckbox value="#{node.checked}" />
<t:graphicImage value="images/yellow-folder-closed.png" border="0"/>
<h:outputText value="#{node.description}" styleClass="nodeFolder"/>
</h:panelGroup>
</f:facet>
...
</t:tree2>
<h:commandLink value="GO" action="#{tree.processNodes}"/>
</h:form>
...
Backing Bean (constructor or init() in case of Shale's ViewControler)
(btw. AnalysisFolder is an business object of me...)
-------------------------
tree = new TreeNodeBase("root","Analyses",false);
for (Iterator iter = listOfAnalysisFolders.iterator(); iter.hasNext();) {
AnalysisFolder element = (AnalysisFolder) iter.next();
tree.getChildren().add(
new TreeNodeChecked("analysisFolder", element.getName(),
element.getId(), false, true));
selectedIds.add(new SelectItem(element.getId()));
}
-------------------------
action method:
-------------------------
public String processNodes(){
List childs = tree.getChildren();
for (Iterator iter = childs.iterator(); iter.hasNext();) {
TreeNodeChecked element = (TreeNodeChecked) iter.next();
if(element.isChecked()==true) {
//do...
}
}
...
}
-------------------------
HTH,
Matthias
On 5/23/06, Philippe Lamote <[EMAIL PROTECTED]> wrote:
Hi,
I'm sory for this question, but there's not too much doc about this
on site, so... here we go:
I want to make a tree2 with checkboxes that I only collect once
together, and I could use some advice:
The examples I've seen, have the commandlink at every node, by
consequence fire off the second one gets clicked.
What I want, is:
- a CLIENT side tree2 (for speed)
- with checkboxes on every leaf element
- multiple leafs can be checked simultaneously ("simultaneously"
meaning before a new request fires off)
- under the tree a cmd button to ONLY THEN fire off an action.
The action should then perform an opeation on all the checked leafs.
I guess thsi is possible, but how to do this best?
If possible, I'd like a solution without javascript to collect the
checked nodes, yet if no other way exits, that's fine too.
With js I thought of smth like: (if it works, "addToRequest(#
{node.identifier});" ... should add the node ID to the request. So
all checked nodes would be sent with the request wen the cmd button
under the tree gets clicked.)
<t:tree2 id="clientTree" value="#{calmgmtbean.treeModel}"
var="node" varNodeToggler="t">
<f:facet name="setsTree">
<h:panelGroup>
<h:selectBooleanCheckbox onclick="addToRequest(#
{node.identifier});" />
<t:graphicImage value="..pics/calMgmt/document.png"
border="0"/>
<h:outputText value="#{node.description}" styleClass="#
{t.nodeSelected ? 'treeSetSelected':'treeSetUnselected'}"/>
</h:panelGroup>
</f:facet>
</t:tree2>
If possible, I would like to get rid of "addToRequest(#
{node.identifier});", of even better of the entire
"h:selectBooleanCheckbox" and use checkedNode (smth Matthias
Wessendorf provided us with for convenience - thank you Matthias! :-)
Yet in that case, how to collect all the ckecked nodes at the server
side?
Is it necessary to walk over all the nodes and perform a isChecked
check? (if so, does someone here has some tested code for this? Would
be a ice addition to http://wiki.apache.org/myfaces/Tree2 as well.
I think this would also be a fine candidate for a build-in method, to
ship with the ckeckNode tree. As with a checkednode tree, you have
the great option to batch process all checked nodes at once,
serverside, compared to all the servertrips per checked node you'd
have without a checkednode tree. (this is what I love most about it,
it's a great idea, yet now I guess every dev has to program the same
method over and over again for tree-traversal)
Thanks in advance,
Phil
--
Matthias Wessendorf
Aechterhoek 18
48282 Emsdetten
http://jroller.com/page/mwessendorf
mwessendorf-at-gmail-dot-com