You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Philippe Lamote <ph...@mac.com> on 2006/05/23 12:11:57 UTC

Tree2 & CheckedNode question

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



Re: Tree2 & CheckedNode question

Posted by Philippe Lamote <ph...@mac.com>.
<snip> Oops, oh well. Didn't take very long at all </snip>

Aiii, and this is a fine example of how to offend Matthias in  
public ;-)  (joke)

Phil

Ps Great minds think alike.

On 23 May 2006, at 22:40, Andrew Robinson wrote:



Re: Tree2 & CheckedNode question

Posted by Andrew Robinson <an...@gmail.com>.
Oops, oh well. Didn't take very long at all

On 5/23/06, Philippe Lamote <ph...@mac.com> wrote:
> Hi Andrew... I'm afraid you did some double work, this is exactly
> what Matthias's TreeNodeChecked does...
> That's why he can do a "element.isChecked()" method inside his
> processing method :-)
> -Phil
>
> On 23 May 2006, at 22:14, Andrew Robinson wrote:
>
> I *JUST* implemented another solution using a custom node:
>
> Node class:
> class CustomNode extends TreeNodeBase {
>   private boolean selected;
>   public boolean isSelected() { return this.selected; }
>   public void setSelected(boolean selected) { this.selected =
> selected; }
> }
>
> XHTML:
> <f:facet name="selectableNode">
>   <t:panelGroup>
>     <t:selectBooleanCheckbox
>       value="#{node.selected}" />
>     <t:outputText value="#{node.description}" />
>   </t:panelGroup>
> </f:facet>
>
> Now the selected state is on the tree node in the model where it
> logically belongs. Now you can just iterate the nodes to determine
> which are selected (or put logic in the setSelected(boolean) method of
> the node).
>
> -Andrew
>
>
>
> On 5/23/06, Philippe Lamote <ph...@mac.com> wrote:
> > Thx Matti, it helped indeed.
> > This is what I was looking for.
> > I believe however this only works for trees having depth==1, whereas
> > Michael's method works for all depths, perhaps that is an advantage.
> > For Michael's method, I wonder whether, if a user changes his mind
> > e.g. 3 times on the same node, producing 3 ValueChangeEvents, the 2
> > redundant VCE will be processed. Also this method would be less
> > efficient with lost of nodes having only few leaves. Like
> > Michaelsaid, it really depends on the biz casus.
> >
> > As for the depth-1 thing, adding a recursive call (like: if hasKids()
> > {recursive_call()_on_kids();}  to your processNodes() method would
> > most likely solve that, making it a depth-first algorithm.
> >
> > & Thanks for the input,
> > Phil
> > Ps Matthias, wouldn't it a good idea to add this to http://
> > wiki.apache.org/myfaces/Tree2 ?
> >
> >
> > On 23 May 2006, at 17:55, Matthias Wessendorf wrote:
> >
> > 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 <ph...@mac.com> 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
> >
> >
>
>

Re: Tree2 & CheckedNode question

Posted by Philippe Lamote <ph...@mac.com>.
Hi Andrew... I'm afraid you did some double work, this is exactly  
what Matthias's TreeNodeChecked does...
That's why he can do a "element.isChecked()" method inside his  
processing method :-)
-Phil

On 23 May 2006, at 22:14, Andrew Robinson wrote:

I *JUST* implemented another solution using a custom node:

Node class:
class CustomNode extends TreeNodeBase {
  private boolean selected;
  public boolean isSelected() { return this.selected; }
  public void setSelected(boolean selected) { this.selected =  
selected; }
}

XHTML:
<f:facet name="selectableNode">
  <t:panelGroup>
    <t:selectBooleanCheckbox
      value="#{node.selected}" />
    <t:outputText value="#{node.description}" />
  </t:panelGroup>
</f:facet>

Now the selected state is on the tree node in the model where it
logically belongs. Now you can just iterate the nodes to determine
which are selected (or put logic in the setSelected(boolean) method of
the node).

-Andrew



On 5/23/06, Philippe Lamote <ph...@mac.com> wrote:
> Thx Matti, it helped indeed.
> This is what I was looking for.
> I believe however this only works for trees having depth==1, whereas
> Michael's method works for all depths, perhaps that is an advantage.
> For Michael's method, I wonder whether, if a user changes his mind
> e.g. 3 times on the same node, producing 3 ValueChangeEvents, the 2
> redundant VCE will be processed. Also this method would be less
> efficient with lost of nodes having only few leaves. Like
> Michaelsaid, it really depends on the biz casus.
>
> As for the depth-1 thing, adding a recursive call (like: if hasKids()
> {recursive_call()_on_kids();}  to your processNodes() method would
> most likely solve that, making it a depth-first algorithm.
>
> & Thanks for the input,
> Phil
> Ps Matthias, wouldn't it a good idea to add this to http://
> wiki.apache.org/myfaces/Tree2 ?
>
>
> On 23 May 2006, at 17:55, Matthias Wessendorf wrote:
>
> 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 <ph...@mac.com> 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
>
>


Re: Tree2 & CheckedNode question

Posted by Andrew Robinson <an...@gmail.com>.
I *JUST* implemented another solution using a custom node:

Node class:
class CustomNode extends TreeNodeBase {
  private boolean selected;
  public boolean isSelected() { return this.selected; }
  public void setSelected(boolean selected) { this.selected = selected; }
}

XHTML:
<f:facet name="selectableNode">
  <t:panelGroup>
    <t:selectBooleanCheckbox
      value="#{node.selected}" />
    <t:outputText value="#{node.description}" />
  </t:panelGroup>
</f:facet>

Now the selected state is on the tree node in the model where it
logically belongs. Now you can just iterate the nodes to determine
which are selected (or put logic in the setSelected(boolean) method of
the node).

-Andrew



On 5/23/06, Philippe Lamote <ph...@mac.com> wrote:
> Thx Matti, it helped indeed.
> This is what I was looking for.
> I believe however this only works for trees having depth==1, whereas
> Michael's method works for all depths, perhaps that is an advantage.
> For Michael's method, I wonder whether, if a user changes his mind
> e.g. 3 times on the same node, producing 3 ValueChangeEvents, the 2
> redundant VCE will be processed. Also this method would be less
> efficient with lost of nodes having only few leaves. Like
> Michaelsaid, it really depends on the biz casus.
>
> As for the depth-1 thing, adding a recursive call (like: if hasKids()
> {recursive_call()_on_kids();}  to your processNodes() method would
> most likely solve that, making it a depth-first algorithm.
>
> & Thanks for the input,
> Phil
> Ps Matthias, wouldn't it a good idea to add this to http://
> wiki.apache.org/myfaces/Tree2 ?
>
>
> On 23 May 2006, at 17:55, Matthias Wessendorf wrote:
>
> 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 <ph...@mac.com> 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
>
>

Re: Tree2 & CheckedNode question

Posted by Philippe Lamote <ph...@mac.com>.
Thx Matti, it helped indeed.
This is what I was looking for.
I believe however this only works for trees having depth==1, whereas  
Michael's method works for all depths, perhaps that is an advantage.
For Michael's method, I wonder whether, if a user changes his mind  
e.g. 3 times on the same node, producing 3 ValueChangeEvents, the 2  
redundant VCE will be processed. Also this method would be less  
efficient with lost of nodes having only few leaves. Like  
Michaelsaid, it really depends on the biz casus.

As for the depth-1 thing, adding a recursive call (like: if hasKids() 
{recursive_call()_on_kids();}  to your processNodes() method would  
most likely solve that, making it a depth-first algorithm.

& Thanks for the input,
Phil
Ps Matthias, wouldn't it a good idea to add this to http:// 
wiki.apache.org/myfaces/Tree2 ?


On 23 May 2006, at 17:55, Matthias Wessendorf wrote:

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 <ph...@mac.com> 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


Re: Tree2 & CheckedNode question

Posted by Matthias Wessendorf <ma...@apache.org>.
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 <ph...@mac.com> 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

Re: Tree2 & CheckedNode question

Posted by Chris Hane <ch...@itsolut.com>.
You might also try something like the jenia components.  I use their 
multipleSelector component with a datatable.  However, I imagine it 
could work with a tree.

Philippe Lamote 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
>
>
>
>
> --No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.392 / Virus Database: 268.7.0/345 - Release Date: 5/22/2006
>
>


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.7.0/345 - Release Date: 5/22/2006