2 Replies Latest reply on Jan 18, 2010 6:46 AM by Alex Drukov

    Getting data to JS selecting treeNode

    Alex Drukov Newbie

      I need to get data from server to use it in my Javascript function, when I cklick any tree node. The code looks like this:

      {code}

      <rich:tree id="tree" ajaxKeys="#{null}" ajaxSubmitSelection="true"
                      switchType="ajax" immediate="true"
                      nodeSelectListener="#{treeManageBean.processSelection}"
                      changeExpandListener="#{treeManageBean.processExpand}"
                      dragIndicator="indicator2" rendered="#{treeManageBean.treeRendered}"
                      value="#{treeManageBean.curTree}" var="item" treeNodeVar="treeNode"
                      dropListener="#{treeManageBean.dropListener}"
                      nodeFace="#{item.type}" rightClickSelection="true"
                      reRender="#{treeManageBean.treeReRenderString}" limitToList="true"
                      process="shownRecordsNum"
                      data="#{treeManageBean.data}"
                      oncomplete="updateData(data);">              
                     
                      <rich:treeNode type="node" id="treeNode" dragType="folder"
                          acceptedTypes="pic, folder" icon="#{item.icon1}"
                          iconLeaf="#{item.icon2}"
                          nodeClass="#{item.selected?'rich-tree-node-sel':''}">
                          <h:outputText value="#{item.nodeName}" />
                      </rich:treeNode>
      </rich:tree>

      {code}

       

      The problen is that data is undefined after ajax request. updateData function is called but the parametr is not passed. treeManageBean.data is not null an the server side.

      What am I doing wrong?

        • 1. Re: Getting data to JS selecting treeNode
          Nick Belaevski Master

          Hi Alex,

           

          Try defining "data" & "oncomplete" on rich:treeNode, not rich:tree.

          • 2. Re: Getting data to JS selecting treeNode
            Alex Drukov Newbie

            Thanks for the answer. I've made somthing like this:


            <rich:tree id="tree" ajaxKeys="#{null}" ajaxSubmitSelection="true"
                            switchType="ajax" immediate="true"
                            nodeSelectListener="#{treeManageBean.processSelection}"
                            changeExpandListener="#{treeManageBean.processExpand}"
                            dragIndicator="indicator2" rendered="#{treeManageBean.treeRendered}"
                            value="#{treeManageBean.curTree}" var="item" treeNodeVar="treeNode"
                            dropListener="#{treeManageBean.dropListener}"
                            nodeFace="#{item.type}" rightClickSelection="true"
                            reRender="#{treeManageBean.treeReRenderString}" limitToList="true"
                            process="shownRecordsNum" >              
                           
                            <rich:treeNode type="node" id="treeNode" dragType="folder"
                                acceptedTypes="pic, folder" icon="#{item.icon1}"
                                iconLeaf="#{item.icon2}"
                                nodeClass="#{item.selected?'rich-tree-node-sel':''}"

                                data="#{treeManageBean.data}"

                                 oncomplete="updateData(data);">    
                                <h:outputText value="#{item.nodeName}" />
                            </rich:treeNode>
            </rich:tree>

             

            But it doesn't work unfortunatelly ((