1 Reply Latest reply on Jul 18, 2012 7:27 AM by Federico Luna

    Tree element on cascade selection problems

    Federico Luna Newbie

      Hi everyone,

       

      I´m trying to generate a tree element with on cascade selection availability using richfaces 3.3.3.Final and jsf 1.2

       

      To do that i´m generating the following rich:tree

       

      my tree

      <rich:column colspan="2" style="border:0;">

      <a4j:outputPanel id="opModTreeNode">

                                                                                      <rich:tree switchType="client" id="modTree" binding="#{beanProfiles.modTree}">

           <rich:recursiveTreeNodesAdaptor

           roots="#{beanProfiles.menusesProfile}" var="item"

           nodes="#{item.children}">

              <rich:treeNode >

                    <h:selectBooleanCheckbox value="#{item.selected}" style="#{item.style}"  />

                            <a4j:support event="onclick"

                                action="cambiarCheckBox()"

                                reRender="opModTreeNode" />

                    <h:outputText value="#{item.strSelected}" style="white-space:nowrap;"></h:outputText>

               </rich:treeNode>

          </rich:recursiveTreeNodesAdaptor>

                                                                                      </rich:tree>

      </a4j:outputPanel>

      </rich:column>

       

      and i´m using the next a4j:jsfuntion to call the backingbean

       

      a4j:jsfunction

      <a4j:jsFunction name="cambiarCheckBox" action="#{beanProfiles.preCambiarCheckBox}">

                          <a4j:actionparam name="#{item.nseqMenu}" assignTo="#{beanProfiles.currentMenuId}"></a4j:actionparam>

      </a4j:jsFunction>

       

      but it´s never access the beanProfiles.preCambiarCheckBox method.

       

      If i run the beanProfiles.preCambiarCheckBox into a4j:support action, it´s access correctly to the backingbean method, but i need to update beanProfiles.currentMenuId with the item.nseqMenu value to know what tree element has been clicked.

       

      Does anyone knows why it isn´t working or a alternative way to update the currentMenuId value with item.nseqMenu value from the .jsp???

       

      Thanks in advance

        • 1. Re: Tree element on cascade selection problems
          Federico Luna Newbie

          Finally i´ve found the solution.

           

          The best way to fix the problem is use <f:setPropertyActionListener> instead of a <a4j:jsfunction>

           

          This functionality allows to reload a backing bean property without problems.

           

          The code remains like below:

           

          <rich:column colspan="2" style="border:0;">

                                                                                <a4j:outputPanel id="opModTreeNode">

              <rich:tree switchType="client" id="modTree" binding="#{beanProfiles.modTree}">

                <rich:recursiveTreeNodesAdaptor

                   roots="#{beanProfiles.menusesProfile}" var="item"

                   nodes="#{item.children}">

                     <rich:treeNode >

                         <h:selectBooleanCheckbox value="#{item.selected}" style="#{item.style}">

                                <a4j:support event="onclick"

                                     action="#{beanProfiles.cambiarCheckBox}"

                                     reRender="opModTreeNode">

                                        <f:setPropertyActionListener value="#{item.nseqMenu}" target="#{beanProfiles.currentMenuId}" />

                                </a4j:support>

                         </h:selectBooleanCheckbox>

                         <h:outputText value="#{item.strSelected}" style="white-space:nowrap;"></h:outputText>

                    </rich:treeNode>

                </rich:recursiveTreeNodesAdaptor>

                                                                                          </rich:tree>

          </a4j:outputPanel>

          </rich:column>