Now if we only understood why :-)

On 7/25/06, Jiang, Jane (NIH/NCI) [C] <[EMAIL PROTECTED]> wrote:
Thanks for the suggestion.  It worked for me!  I wish I understand more about 
it.  Is there any documentation on it?  I hope I am not losing anything by 
using the transient mode.  I tried to trace my code in the debugging mode.  The 
getTreeModel() still got called twice except both times returned the same 
treeState.

Jane

-----Original Message-----
From: Andrew Robinson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 25, 2006 3:57 PM
To: MyFaces Discussion
Subject: Re: tree2: update treeModel on the server


Stab in the dark (almost):

Try setting the tree model's tree state to transient. I have seen some
weird behaviors when the default (non-transient) is used. I don't
fully understand it (didn't spend the time learning the source code
for the control), but it has something to do with the tree model, tree
state and/or tree nodes being cached when transient is false.

-Andrew

On 7/25/06, Jiang, Jane (NIH/NCI) [C] <[EMAIL PROTECTED]> wrote:
>
>
> Hi all,
>
> I am having problem updating the tree model.  Here is my short code sample
>
> JSP
>     <h:commandLink value="Refresh tree" action="#{treeBacker.refreshTree}"/>
>     <br/><br/>
>
>     <!-- Expand/Collapse Handled By Server -->
>     <t:tree2 id="serverTree" value="#{treeBacker.treeModel}" var="node"
> varNodeToggler="t" clientSideToggle="false" binding="#{treeBacker.tree}">
>
> TreeBacker.java
>
> ...   public String refreshTree()   {
>        treeData.refreshTree();
>        _treeModel = new TreeModelBase(treeData.getTreeData());
>        return null;
>    }
>    public TreeModel getTreeModel() {
>       if (_treeModel == null) {
>          _treeModel = new TreeModelBase(treeData.getTreeData());
>          _treeModel.getTreeState().toggleExpanded("0");
>       }
>
>       return _treeModel;
>    }
>
> I setup breakpoint to see what is going on.  It seems like refreshTree() get
> called, _treeModel is updated.  Then getTreeModel() got called twice.  The
> first time it returned the updated one, then the second time it returned the
> old one.
>
> My treeBacked is defined in the session scope as follow.  So there should
> not be two instances of treeBacker for the same session.
>
>     <managed-bean>
>         <managed-bean-name>treeBacker</managed-bean-name>
>
> 
<managed-bean-class>gov.nih.nci.ncicb.cadsr.umlmodelbrowser.tree.TreeBacker</managed-bean-class>
>         <managed-bean-scope>session</managed-bean-scope>
>     </managed-bean>
>
> Any suggestions on how to get this to work or other ways to refresh the tree
> would be grealy appreciated.
>
> Many thanks,
>
> Jane

Reply via email to