FYI the latest source code contains a configurable TreeModel as well
as a setExpandAll method on TreeModelBase.

See MYFACES-353 and MYFACES-390 for details.  

Also, your backing beans will have to return TreeModel now instead of
TreeNode.  Sorry about the minor rewrite :-(

sean

On 7/25/05, Edwin Mercado <[EMAIL PROTECTED]> wrote:
> It's in the session scope.
> 
> -----Original Message-----
> From: Dennis Byrne [mailto:[EMAIL PROTECTED]
> Sent: Sunday, July 24, 2005 1:22 AM
> To: MyFaces Discussion
> Subject: RE: tree3 component reload
> 
> 
> What scope is your backer in?  If it is in request, see if
> this "deja vu" effect is still there after doing the
> following:
> 
> 1.) move bean into session scope.
> 2.) You may already be doing this, but make sure
> the "createProArgumentationNode()" method updates both
> underlying data source and the object model (in your case
> Edwin, the property called 'treeData' .
> 3.) in the 'getTreeData', test 'treeData' for the null case.
> If it is null, assign it to the result of loadTreeData() and
> return it, otherwise just return 'treeData' .
> 
> ---- Original message ----
> >Date: Sat, 23 Jul 2005 16:09:54 -0400
> >From: Edwin Mercado <[EMAIL PROTECTED]>
> >Subject: RE: tree3 component reload
> >To: MyFaces Discussion <[email protected]>
> >
> >I don't consider this a "bright idea" but a workaround
> (i.e., hack)
> >to the current shortcoming. I was able to temporarily solve
> this
> >issue (of having the tree2 component not displaying the
> updated tree value
> >immediately)
> >by adding an action method, besides the actionListener, to
> >the commandLink adding the node.
> >
> >               <h:commandLink value="#{labels.add_pro} "
> >                       styleClass="document"
> >                       immediate="true"
> >                       action="#{treeBacker.updateView}"
> >
> >actionListener="#{treeBacker.createProArgumentationNode}">
> >                       <h:graphicImage
> value="images/ProNodeIcon.gif"
> >border="0" />
> >               </h:commandLink>
> >
> >The action method does two things:
> >       1) renders the view with the NEWLY ADDED NODE
> >               (added in the actionListener) and
> >       2) forces a reload of the current page.
> >
> >If you do just one of either steps, you'll continue
> experience the same
> >effect as before (display of the old tree view). I don't
> under JSF
> >enough to explain the reasoning behind this. I just know
> that it
> >does what I want :)
> >
> >The action method (i.e., treeBacker.updateView) looks like
> this:
> >
> > public String updateView() {
> >
> >  FacesContext context = FacesContext.getCurrentInstance();
> >  ViewHandler viewHandler = context.getApplication
> ().getViewHandler();
> >  UIViewRoot viewRoot = context.getViewRoot();
> >  try  {
> >   viewHandler.renderView(context, viewRoot);
> >  }  catch (IOException ioex)  {
> >   logger.severe(ioex.getCause().toString());
> >  }
> >
> >  return "UpdateViewAction";
> > }
> >
> >Edwin
> >p.s. waiting for a better solution (maybe inside of the
> tree2 code)
> >-----Original Message-----
> >From: Dennis Byrne [mailto:[EMAIL PROTECTED]
> >Sent: Saturday, July 23, 2005 1:19 AM
> >To: MyFaces Discussion
> >Subject: RE: tree3 component reload
> >
> >
> >I'm getting the same behavior as both of you.  I get it with
> >@action and @actionListener .  I get it with the HEAD branch
> >and 1.0.9 .  I get it when I add nodes and remove nodes.
> >
> >I'll take a look this weekend.  If there aren't any bright
> >ideas between now and next week, I'll open a bug so that we
> >can discuss this at the "tree2 summit" .
> >
> >---- Original message ----
> >>Date: Fri, 22 Jul 2005 17:44:40 -0400
> >>From: "Vo, Ky" <[EMAIL PROTECTED]>
> >>Subject: RE: tree3 component reload
> >>To: "'MyFaces Discussion'" <[email protected]>
> >>
> >>Hi,
> >>
> >>I had the exact problem using tree2.  I started to play
> >around with the
> >>setValue method from HtmlTree.  It seems to do the trick.
> >The only problem
> >>is the initial click to process the actionListener.  (I'm
> >still trying to
> >>solve this problem (bug?))  After going to load my initial
> >tree, I click on
> >>a node to process the actionListener.  It seems to be
> >reloading the initial
> >>tree again after I click on the node and it doesn't expand
> >the node.  After
> >>that initial click on the tree, the actionListener works
> >like its supposed
> >>to and adds children to the tree with every click.
> >Maybe "<x:tree2
> >>value="#{treeBacker.treeData" ... >" is not being set
> >correctly on the
> >>initial load of the page.  Do I somehow need to do a
> >setValue in my
> >>treeData() method like in the processAction method for the
> >actionListener?
> >>
> >>-Ky
> >>
> >>Here's the code I used:
> >>
> >>In JSP
> >>-----
> >>              <x:tree2 value="#{treeBacker.treeData}"
> >id="server-tree"
> >>                      var="node" varNodeToggler="t"
> >>clientSideToggle="false" showRootNode="false">
> >>                      <f:facet name="tree-type">
> >>                              <h:panelGroup>
> >>                                      <h:commandLink
> >immediate="true"
> >>action="#{t.toggleExpanded}">
> >>
> >       <f:actionListener
> >>type="com.x.TreeBackerListener"/>
> >>
> >       <h:graphicImage
> >>value="/images/yellow-folder-open.png"
> >>
> >>rendered="#{t.nodeExpanded}" border="0" />
> >>
> >       <h:graphicImage
> >>value="/images/yellow-folder-closed.png"
> >>
> >>rendered="#{!t.nodeExpanded}" border="0" />
> >>                                      </h:commandLink>
> >>                                      <h:outputText
> >>value="#{node.description}" styleClass="nodeFolder" />
> >>                              </h:panelGroup>
> >>                      </f:facet>
> >>              </x:tree2>
> >>
> >>In class TreeBackerListener
> >>----
> >>public class StudyDBTreeListener implements ActionListener {
> >>
> >>      public TreeNode treeData() {
> >>              TreeNode treeData = new TreeNodeBase("tree-
> >type", "Tree
> >>Description", true);
> >>
> >>              TreeNode newNode = new TreeNodeBase("tree-
> >type",
> >>"Description", "Identifier", true);
> >>              treeData.getChildren().add(addModelNode);
> >>
> >>              return treeData;
> >>      }
> >>
> >>      public void processAction(ActionEvent actionEvent) {
> >>
> >>              UIComponent component =
> >actionEvent.getComponent();
> >>              UIComponent parent = component.getParent
> >().getParent();
> >>
> >>              HtmlTree tree = (HtmlTree) parent;
> >>
> >>              TreeNode treeData = tree.getNode();
> >>              String treeType = treeData.getType();
> >>
> >>              //Important to check to see if node has any
> >children.
> >>              //Without the children check, it adds the
> >same childen to
> >>the
> >>              //node over again (if this is what you want
> >then take out
> >>the
> >>              //child count check.
> >>              if(treeType.equals("tree-type") &&
> >treeData.getChildCount()
> >>== 0){
> >>
> >>                      TreeNode newNode = new TreeNodeBase
> >("tree-type",
> >>"description",
> >>                                              "identifier",
> >true);
> >>                      treeData.getChildren().add(newNode);
> >>
> >>              }
> >>
> >>              TreeNode treeDataRoot = (TreeNode)
> >tree.getValue();
> >>              tree.setValue(treeDataRoot);
> >>
> >>      }
> >>}
> >>
> >>-----Original Message-----
> >>From: Edwin Mercado [mailto:[EMAIL PROTECTED]
> >>Sent: Friday, July 22, 2005 1:43 PM
> >>To: MyFaces Discussion
> >>Subject: RE: tree3 component reload
> >>
> >>
> >>Here's the action listener for the add child node
> >>command link:
> >>
> >> public void createProArgumentationNode(ActionEvent event)
> >> {
> >>  ArgumentationNode child = createNode();
> >>  ArgumentationNode parent = getCurrentNode();
> >>  addEdge(child, parent, true);
> >>
> >>  /* view updated model data */
> >>  focusNode(event, child);
> >>  toggleSelectedNode();
> >>
> >> }
> >>loadTreeData() gets called twice by the getTreeData()
> >>BEFORE the addition of the new node and once AFTER.
> >>Apparently, the tree model is updated with the previous
> >(old) data.
> >>
> >>Edwin
> >>-----Original Message-----
> >>From: Dennis Byrne [mailto:[EMAIL PROTECTED]
> >>Sent: Friday, July 22, 2005 4:34 PM
> >>To: MyFaces Discussion
> >>Subject: Re: tree3 component reload
> >>
> >>
> >>Can you post the code for your action listener?  I'm
> curious
> >>to see if loadTreeData() is being called after or before
> you
> >>updating the tree model.
> >>
> >>---- Original message ----
> >>>Date: Fri, 22 Jul 2005 15:40:22 -0400
> >>>From: Edwin Mercado <[EMAIL PROTECTED]>
> >>>Subject: tree3 component reload
> >>>To: [email protected]
> >>>
> >>>Hello all,
> >>>I'm still baffled by the JSF phases. I'm using a tree3
> >>component
> >>>that is a tied to a getTreeData() function to retrieve the
> >>current data
> >>>from the model. Everytime I select a node, the getTreeData
> ()
> >>function is
> >>>called 3 times, retrieving the same data every time.
> >>>
> >>><a:tree3 expandAllInit="true" id="networkTree"
> >>>                             value="#
> >>{treeBacker.treeData}" var="node"
> >>>varNodeToggler="t"
> >>>                             clientSideToggle="true">
> >>>...
> >>></a:tree3>
> >>>
> >>> public TreeNode getTreeData()  {
> >>>  treeData = loadTreeData();
> >>>  return treeData;
> >>> }
> >>>
> >>>
> >>>Now, for each tree3 node that has been selected I display
> >>>a command link to add a child node.
> >>>
> >>>             <h:commandLink value="#{labels.add_pro} "
> >>>                     styleClass="document"
> >>>                     action="UpdateViewAction"
> >>>
> >>>actionListener="#{treeBacker.createProArgumentationNode}">
> >>>                     <h:graphicImage
> >>value="images/ProNodeIcon.gif"
> >>>border="0" />
> >>>             </h:commandLink>
> >>>
> >>>Whenever I click add child node command
> >>>link, the getTreeData() is called 3 times, but with a
> >>little "twist". This
> >>>is
> >>>how it goes:
> >>>
> >>>1st time:    getTreeData() gets called and returns the
> >>already displayed
> >>>data
> >>>2nd time:    similar steps as in the 1st time.
> >>>====> the actionListener for the add child node command
> link
> >>gets called.
> >>>     The model is updated with the appropriate value.
> >>>3rd time:    getTreeData() gets called but this time it
> >>gets the updated
> >>>     model value.
> >>>
> >>>Unfortunately, after the 3rd time that getTreeData() got
> >>called with the
> >>>updated
> >>>model value, the tree3 component displays only the
> previous
> >>stored value.
> >>>Now, if I selected a node THEN the updated value (the added
> >>node) gets
> >>>displayed.
> >>>
> >>>My question is how can I make the tree3 component display
> >>the most recent
> >>>model data?
> >>>
> >>>Thanks
> >>>Edwin
> >>>p.s. I experience the same effect using the tree2 component
> >>instead of the
> >>>tree3.
> >>>
> >>>
> >>Dennis Byrne
> >>
> >>
> >>************************************************************
> *
> >********
> >>This message and any attachments are solely for the
> intended
> >recipient. If you are not the intended recipient,
> disclosure,
> >copying, use or distribution of the information included in
> >this message is prohibited -- Please immediately and
> >permanently delete.
> >>
> >Dennis Byrne
> Dennis Byrne
>

Reply via email to