3 Replies Latest reply on Feb 26, 2009 11:21 AM by nbelaevski

    CommandLink in Tree does not work until node is selected

    fritzr

      Hi together,
      I've got a strange problem with my richfaces:tree. I tried to insert some commandLinks which are calling the same action with different parameters. Further we want to listen for treeNodeSelections.

      The problem is now, that the link of the commandLink will not work, because the tree gets the first event (selectNode).

      My question is:
      How can I change my code, so that I don't have to select the row before it is possible to follow my commandLinks? In other words: can I change the priority of the commandLinks, so that they are called before?

      <rich:tree nodeSelectListener="#{structureViewController.processSelection}"
       componentState="#{structureTreeHelper.treeState}"
       toggleOnClick="true"
       highlightedClass="highlightedTreeRow" selectedClass="selectedTreeRow"
       reRender="subMenuPanel" ajaxSubmitSelection="true" >
      
      ...
      
      <rich:treeNodesAdaptor var="system" nodes="#{system.subsystems}">
      
       <rich:treeNode icon="${request.contextPath}/../images/icons/plugin.png" iconLeaf="${request.contextPath}/../images/icons/plugin.png">
       <div class="treeNodeLabel">
       <h:outputText value="#{system.title}" id="subSystemNodeLabel"/>
       </div>
       <div class="treeNodeRightContent">
       <t:dataList var="systemRiskType" value="#{system.riskTypes}" layout="simple">
       <h:commandLink action="editSRT" >
       <f:param name="riskTypeId" value="#{systemRiskType.id}"/>
       <span class="systemRiskType" title="#{systemRiskType.riskType.name}">
       <h:outputText value="#{systemRiskType.riskType.code}"/>
       </span>
       </h:commandLink>
       </t:dataList>
       </div>
      


        • 1. Re: CommandLink in Tree does not work until node is selected
          nbelaevski

          Hello,

          No, it's not possible selection happens by "mousedown" event and h:commandLink is submitted by "click" event ("mousedown" + "mouseup"). Please describe why do you need to do this, maybe I'll be able to suggest something?

          • 2. Re: CommandLink in Tree does not work until node is selected
            fritzr

            Hi,
            I have the following UseCase:
            The tree shows machines, systems and subsystems. Based on the selection, another panel is filled with additional information. Thus I need the selectionListener. Another reason for the selectionListener is the use of my context menu, which needs the current node for further processes.

            The commandLinks display dxynamic n:m relations, called RiskTypes. With a click on these -items a subflow is started and we proceed with another page.

            In some way, you can compare this functionality with a tree table. I figured out, that it might be a solution to use the requestDelay, cause than the click-event will proceed. In general i try to avoid making the application slower than it needs to. See the screenshot attached for an overview.


            [img]http://www.fritzr.de/screenshot.jpg[/img]
            http://www.fritzr.de/screenshot.jpg

            • 3. Re: CommandLink in Tree does not work until node is selected
              nbelaevski

              I suggest that you disable ajax selection submits. Try this:

              <rich:tree switchType="ajax" ajaxSubmitSelection="false" nodeSelectListener="#{forum5Bean.processNodeSelection}">
               <rich:recursiveTreeNodesAdaptor roots="#{forum5Bean.rootNodes}" var="item" nodes="#{item.children}">
               <rich:treeNode><h:commandLink styleClass="treeLink" onmousedown="window.treeLink = true;">#{item.locationName}</h:commandLink> - text
              
               <a4j:support event="onselected" onsubmit="if (window.treeLink) {window.treeLink = false; return true;}"/>
               </rich:treeNode>
               </rich:recursiveTreeNodesAdaptor>
               </rich:tree>