You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Eric Hsieh <ec...@yahoo.com> on 2005/03/30 01:58:12 UTC

Fwd: Re: Another tree2 question

Sean,

If there was a way to remotely set the currently
selected node in tree2 that would be fantastic.

Possibly setting the nodeselected in the backing tree
bean or something?

--- Sean Schofield <se...@gmail.com> wrote:
> Date: Fri, 25 Mar 2005 08:31:52 -0500
> From: Sean Schofield <se...@gmail.com>
> To: MyFaces Development
> <my...@incubator.apache.org>
> Subject: Re: Another tree2 question
> 
> Eric,
> 
> Right now the selected node is set through the
> ActionListener
> mechanism.  Your popup window can't really interract
> with the tree in
> this manner (at least the way the tree is now.)
> 
> The main challenge here is that the tree is like
> dataTable.  The
> renderer iterrates over the data one node at a time.
>  The same happens
> for the ActionEvents.  So as its decoding if it
> realizes a node was
> clicked it can mark the *current* node as selected.
> 
> Perhaps we could modify tree2 to allow you to
> specify a nodeId and
> also allow you to set the selected node that way. 
> Would that help?
> 
> sean
> 
> ps. These kinds of questions are better posted on
> the myfaces-user
> list.  No big deal ...
> 
> 
> On Thu, 24 Mar 2005 10:59:37 -0800 (PST), Eric Hsieh
> <ec...@yahoo.com> wrote:
> > Along the same lines as my earlier question
> regarding
> > current node selection (Thanks Matthias for
> forwarding
> > Sean's answer!), is there any way to remotely set
> the
> > currently selected node in the tree?
> > 
> > My scenario is the following: from a popup window
> I'm
> > adding a new element to the db.  This element will
> > appear in the tree in the main window whenever the
> > tree refreshes.  I want the element that was just
> > added to be selected once the tree refreshes.
> > Possible?
> > 
> > FYI, I'm creating a tree of TreeNodeBase nodes. 
> Could
> > I look up the object populating <x:tree2 value="">
> and
> > set a selected flag on one of the nodes?
> > 
> > 
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Small Business - Try our new resources
> site!
> > http://smallbusiness.yahoo.com/resources/
> >
> 


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Easier than ever with enhanced search. Learn more. 
http://info.mail.yahoo.com/mail_250

Re: Tree2 extension

Posted by Duong BaTien <du...@gmail.com>.
Sean Schofield wrote:

>>1) In the example, the commandLink wraps over the folder graphic and the
>>node description while the nav-plus and nav-minux are handled by the
>>tree2. The result is that a click on nav-plus and nav-minus on my
>>implementation does not do anything. I look at the example of the
>>server-side tree, nav-plus and nav-minus do response. So, i prabably
>>miss something from tree2 htmlTree besides the toggleExpanded(). Any
>>other setting and/or method i need to activate from htmlTree when user
>>selects a node? (i enclose my tree2 setting for your reference).
>>    
>>
>
>This is a known limitation.  We're working on coming up with a
>solution that would work for *both* client and server-side toggle.
>  
>
Please announce when a solution is ready.

> 
>  
>
>>2) Is there any way to just display the level below the root and NOT to
>>display the root as default display? This will save user 1 click and
>>premium space on a web page.
>>    
>>
>
>Yes.  Use showRootNode=false.  That will be more obvious once we have
>some documentation in place. :-)
>
>  
>
Excellent. It works :-) This means tree2 can now be a part of a very 
sophisticated page similar to a multi-level marketing report, shown in 
the list to request features from tree2.

>>3) Currently, the TreeBackend.java harcodes the treeData. Is there any
>>thought (1) to use IoC configuration to set the treeData content for the
>>default and (2) the content will be updated from the database and make
>>tree2 immediately responses to the new content?
>>    
>>
>
>I would defnitely not hardcode the data in a real application.  There
>are a variety of mechanisms for updating the data but its not
>something specific to tree2.  Think dataTable and apply the same
>solution to tree2.  As for refreshing with new data that will happen
>during renderResponse (same as a dataTable.)  There is no way to
>"push" the new tree obviously because we're talking HTML which is a
>request/response model.
>  
>
Following is our solution. I look for comments/suggestions from others, 
especially from Craig. Hope this may help others as well.

There is a report somewhere about the limitation of Jsf lifecycle to 
reload the content of its backing beans in session scope. One suggested 
solution is to programmatically delete the backing bean and reload it 
with new content. I do not use this approach.

Rather, i use Struts-Shale DialogController as backing bean and 
ViewController to control the initial state of the DialogController. In 
this way, the same DialogController will be able to serve different 
contents from ViewController. A good thing is that i am able to 
implement this mechanism as nested tabs using current myfaces tiles 
viewHandler :-).

BaTien
DBGROUPS

>HTH,
>sean
>
>  
>
>>BaTien
>>
>
>
>  
>


Re: Tree2 extension

Posted by Sean Schofield <se...@gmail.com>.
> 1) In the example, the commandLink wraps over the folder graphic and the
> node description while the nav-plus and nav-minux are handled by the
> tree2. The result is that a click on nav-plus and nav-minus on my
> implementation does not do anything. I look at the example of the
> server-side tree, nav-plus and nav-minus do response. So, i prabably
> miss something from tree2 htmlTree besides the toggleExpanded(). Any
> other setting and/or method i need to activate from htmlTree when user
> selects a node? (i enclose my tree2 setting for your reference).

This is a known limitation.  We're working on coming up with a
solution that would work for *both* client and server-side toggle.
 
> 2) Is there any way to just display the level below the root and NOT to
> display the root as default display? This will save user 1 click and
> premium space on a web page.

Yes.  Use showRootNode=false.  That will be more obvious once we have
some documentation in place. :-)

> 3) Currently, the TreeBackend.java harcodes the treeData. Is there any
> thought (1) to use IoC configuration to set the treeData content for the
> default and (2) the content will be updated from the database and make
> tree2 immediately responses to the new content?

I would defnitely not hardcode the data in a real application.  There
are a variety of mechanisms for updating the data but its not
something specific to tree2.  Think dataTable and apply the same
solution to tree2.  As for refreshing with new data that will happen
during renderResponse (same as a dataTable.)  There is no way to
"push" the new tree obviously because we're talking HTML which is a
request/response model.

HTH,
sean

> BaTien

Re: Tree2 extension

Posted by Duong BaTien <du...@gmail.com>.
Hello Sean and the very active List:

First, thanks for the latest examples and a nice tree2 demo. I looked at 
tree2 source code and decided to leverage available codes of tree2 for 
tree rendering while using actionListener and action of the configurable 
commandLink to wire user selected node to backend processing.

For that purpose, i (1) have my own implementation of TreeNodeBase so i 
can have other properties as required. (2) access the HtmlTree and call 
toggleExpanded() to transmit user selected node to tree2 before doing my 
own backend processing under commandLink actionListener. Things work as 
expected thanks to Sean effort :-). However, there are some issues that 
i look for suggestions/solutions:

1) In the example, the commandLink wraps over the folder graphic and the 
node description while the nav-plus and nav-minux are handled by the 
tree2. The result is that a click on nav-plus and nav-minus on my 
implementation does not do anything. I look at the example of the 
server-side tree, nav-plus and nav-minus do response. So, i prabably 
miss something from tree2 htmlTree besides the toggleExpanded(). Any 
other setting and/or method i need to activate from htmlTree when user 
selects a node? (i enclose my tree2 setting for your reference).

2) Is there any way to just display the level below the root and NOT to 
display the root as default display? This will save user 1 click and 
premium space on a web page.

3) Currently, the TreeBackend.java harcodes the treeData. Is there any 
thought (1) to use IoC configuration to set the treeData content for the 
default and (2) the content will be updated from the database and make 
tree2 immediately responses to the new content?

Thanks

BaTien
DBGROUPS


Re: Re: Another tree2 question

Posted by Sean Schofield <se...@gmail.com>.
> If there was a way to remotely set the currently
> selected node in tree2 that would be fantastic.
> 
> Possibly setting the nodeselected in the backing tree
> bean or something?

It would be possible but I don't think this would be very useful in
too many situations.  I would imagine that the most common scenario of
a node being "selected" would come from direct user manipulation of
the tree.  Your scenario involves "selecting" the node for the user
because of an action taken in a popup window.  That's fine but I don't
think its too common.

Here are a couple of alternatives for you to consider:

1.) Try to make this work with the existing code base.  You could
write your own subclass of TreeNodeBase.  TreeNodeBase is really just
the bare minimum you need, it was intended to be subclassed.  You
could have a selected property in this node class that you could set
yourself.  Then you could use the "node" reference to determine
whether or not to render the node as selected.

<x:tree2 id="clientTree" value="#{treeBacker.treeData}" var="node"
varNodeToggler="t">

...

   <f:facet name="document">
    <h:panelGroup>
      <h:commandLink immediate="true" styleClass="document"
actionListener="#{t.setNodeSelected}" rendered="#{!node.selected}">
        <h:graphicImage value="/images/document.png" border="0"/>
        <h:outputText value="#{node.description}"/>
        <f:param name="docNum" value="#{node.identifier}"/>
      </h:commandLink>
      <h:commandLink immediate="true" styleClass="documentSelected"
actionListener="#{t.setNodeSelected}" rendered="#{node.selected}">
        <h:graphicImage value="/images/document.png" border="0"/>
        <h:outputText value="#{node.description}"/>
        <f:param name="docNum" value="#{node.identifier}"/>
      </h:commandLink>
    </h:panelGroup>
  </f:facet>

...

</x:tree2>

You would take care of maintaining the selected value of the nodes
yourself which should be easy enough to do since you can access the
tree data at any time.

2.) Subclass HtmlTree and provide a method to set the selected value
of the node.  This might be even easier than option#1.

HTH,

sean