You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Jochen List (JIRA)" <de...@myfaces.apache.org> on 2010/11/10 09:48:15 UTC

[jira] Created: (TOMAHAWK-1556) tree2: Programatically setting of Treestate does only work on the first time

tree2: Programatically setting of Treestate does only work on the first time
----------------------------------------------------------------------------

                 Key: TOMAHAWK-1556
                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1556
             Project: MyFaces Tomahawk
          Issue Type: Bug
          Components: Tree2
    Affects Versions: 1.1.9
         Environment: MyFaces 1.1.1, Java SUN JDK 1.5. update 12, Bea Weblogic 9.2 MP3, Windows XP SP3
            Reporter: Jochen List


I have a problem with resetting the state and Model of tree2 component.

On the Jsp a tree2 Component is placed. If the user clicks on a node, the node is marked as selected and highlighted with css. This works fine. Also on the page, there is a commandLink "Reset", which should resets the tree. Resetting means, that the root node will be selected and of course, highlighted with css.

If the users clicks on a treenode, the node is correctly marked as selected and highlighted. But if the users clicks on the reset Link, the root node will not be seleceted. The view shows the old node as selected. No reset is possible.

In my reset method in the ManagedBean, which is connected to the Reset commandLink, I'm creating a new treemodel, setting the path to the selected node, and setting the model to the tree. I have tried both options, recreating model and tree and only updating the model. Nothing worked as expected. In both cases, the old node is shown as selected.

I have debugged throw the code and in theBackingBean, everythink is correctly set. I can see the variables of htmlTree and treeModel and everythink looks like expected. Then I have debugged the isNodeSelected() Method of the tree, and I can see, that the getDataModel() Method of UITreeData returns a "_cachedModel" variable which contains the old model, with the old selected node. And this model seam to be used for rendering the jsp

The JSP Code:
<t:tree2 value="#{bean.model}" showRootNode="false" var="node"
     varNodeToggler="t" binding="#{bean.htmlTree}" clientSideToggle="false">
     <f:facet name="orga">
         <h:panelGroup>
             <t:commandLink immediate="false" styleClass="#{t.nodeSelected ? 'selectedNode':'standardNode'}" actionListener="#{t.setNodeSelected}"
 action="#{bavCockpitBean.updateNodeList}">
                <t:graphicImage value="images/person.png" border="0" alt="TreeIcon"/>
                <h:outputText value="#{node.description}" />
             </t:commandLink>
        </h:panelGroup>
     </f:facet>
</t:tree2>


The ManagedBean Code:
private HtmlTree htmlTree = null;
private TreeModelBase treeModel = null;
private boolean forceTreeUpdate = true;

public String reset() {
    this.forceUpdate = true;
    return "success";
}

public TreeModel getHirarchieModel() {
    if ( forceUpdate ) {
        this.forceUpdate = false;
        TreeNode root = ... // Generating the tree;

        this.treeModel = new TreeModelBase(root);
        this.treeModel.getTreeState().setSelected( "0:0" );

        this.htmlTree = new HtmlTree();
        tree.setModel(this.treeModel);

        return this.treeModel;

}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.