2 Replies Latest reply on Sep 18, 2008 12:51 PM by hansfl

    Richfaces tree control setting value of control in treeNode

    hansfl

      Hi I am quite new to JSF and Richfaces.
      I am building a prototype Java EE app using the Richfaces tree component.
      I am using the recursiveTreeNodesAdaptor component and setting the rendered attribute of each treeNode element depending on properties of the var object attribute of the recursiveTreeNodesAdaptor component.

      The problem I am having is that the value property of each component within the treeNode component is updated on each request, even if no value is actually defined for that child component. I have a custom control with a valueChangeEvent assigned that gets called for each request because the "old" value is always null as set by the tree component (from what I can see from the call stack).

      Is there a way for the value of a child control of the treeNode component not to be set on a request?

      Or is there something I can do in my custom control for this not to be set by the tree component?

      My custom control works well when not used within the tree control.

      Also another issue I am getting is that javascript mouse click events on the document object are not fired when clicked on the tree control.
      Some of my custom components use a document onclick event to detect where the mouse was clicked to hide popups, and they are not fired when clicking the tree control.

      Is there a way around this?

      Thank you for your help.
      And also want to say that I really like the richfaces and a4j libraries.

      Hans Fladsrud

        • 1. Re: Richfaces tree control setting value of control in treeN
          nbelaevski

          Hans,

          Do you have the same values of rendered attribute when processing request and rendering response? Can you please minify the sample and post page/bean code?

          About click event stopped: what is your RF version?

          • 2. Re: Richfaces tree control setting value of control in treeN
            hansfl

            Hi,

            I got the problem with the values being set solved.
            There was a problem with the name of the html input that was used to hold the value,
            so the value is still set but with the correct value so ValueChangeListeners are not called on each request.

            I have been using FR 3.2.1 GA and I updated to 3.2.2 GA today.
            The issue with the click event is still present.

            Today I also notised some other issues. (With both 3.2.1 and 3.2.2).

            The values in the displayed nodes are not always being updated when the underlying model is changing.
            I have verified that the values in the model is correct, and even after refreshing the page, the value in the treenode from the "old" tree node item is still there.

            From what I have seen so far it is the first level as defined in the "roots" attribute in the recursiveTreeNodesAdapter that is not being updated.
            Then its children are fine. But then its children again sometimes have the same problem.

            My JSF code is below.

            <rich:tree id="uitree" binding="#{todoPageBean.toDoTree}"
             style="width:100%"
             switchType="ajax" rowKeyVar="rowKey"
             nodeSelectListener="#{todoPageBean.nodeSelected}"
             onselected="rtnOnNodeSelection(event)"
             adviseNodeSelected="#{todoPageBean.adviseNodeSelected}"
             adviseNodeOpened="#{todoPageBean.adviseNodeOpened}"
             dropListener="#{todoPageBean.nodeDropped}"
             changeExpandListener="#{todoPageBean.nodeExpandCollapse}"
             >
             <rich:recursiveTreeNodesAdaptor id="itemNode"
             var="itemNode"
             nodes="#{itemNode.children}"
             roots="#{todoPageBean.treeModel.root.children}"
             >
             <rich:treeNode rendered="#{itemNode.nodeType.class.name == 'com.mycompany.model.tree.RtnDefaultNodeType'}"
             onkeyup="rtnDoTreeNodeAction(event, this)"
             id="deftreenode"
             dragType="default"
             acceptedTypes="default, resource"
             >
             <rich:inplaceInput value="#{itemNode.name}"
             id="deftreenodeinput"
             onviewactivated="rtnDefToDoEditComplete(event)"
             inputWidth="300px"
             selectOnEdit="true"
             styleClass="content"
             viewClass="content"
             viewHoverClass="content"
             changedClass="content"
             changedHoverClass="content"
             controlClass="content"
             controlHoverClass="content"
             controlPressedClass="content"
             editClass="content"
             editEvent="ondblclick"
             style="background-color: #{itemNode.nodeType.colour}"/>
             <rich:dndParam name="defdraglabel" type="drag" value="#{itemNode.name}" />
             </rich:treeNode>
             <rich:treeNode id="listlookuptreenode"
             rendered ="#{itemNode.nodeType.class.name == 'com.mycompany.model.tree.RtnListLookupNodeType'}">
             <h:panelGrid columns="2" columnClasses="lookupCol1, lookupCol2">
             <h:outputLabel styleClass="content"
             value="#{itemNode.tableName}: " />
             <rtn:multiValueSelect id="lookuptreecontrol" width="400"
             tableName="#{itemNode.tableName}" fieldName="name"
             valueChangeListener="#{todoPageBean.subNodeNamesChanged}"
             onBeforeChange="rtnSetSelectedFromLookupControl"
             value="#{itemNode.value}"
             query="#{itemNode.tableQuery}"
             >
             <a4j:support event="onChange" reRender="#{todoPageBean.defaultReRender}" />
             </rtn:multiValueSelect>
             </h:panelGrid>
             </rich:treeNode>
             <rich:treeNode>
            
             </rich:treeNode>
             <rich:treeNode id="defedittreenode"
             rendered="#{itemNode.type == 'edit'}">
             <h:inputText value="#{itemNode.name}"
             styleClass="content"
             style="width:100%"
             onkeydown="rtnSubmitNode(this, 'frm-todo-mng:cmdSaveTreeNode')"
             onmousedown="rtnSelectNodeForParent(this)"
            
             />
             </rich:treeNode>
            
             </rich:recursiveTreeNodesAdaptor>
            
            </rich:tree>



            Another thing I am having a bit of problems with is selecting a node just before an ajax request is sent.
            When the valueChangeListener of the rtn:multiValueSelect component is called,
            it is called before the nodeSelectListener function defined in the rich:tree component.
            This way I do not get the currently selected node when in the valueChangeListener function.

            Is there a way to define in which order these event functions are called?

            Thanks alot for your help.

            Hans