3 Replies Latest reply on May 18, 2009 1:51 PM by brian13

    Richfaces limitation to display rich:effect programmatically

    brian13

      I am faced with a rather tricky situation in Richfaces that seems to be
      a limitation in the rich:effect
      I am dynamically creating a rich:tree via recursiveTreeNodesAdaptor that is reRendered via a poll function ... new node events
      may be generated in the program for which I have the nodeEvent flag set. Now based on the nodeEvent flag of a node I am renderering
      the rich:effect for the particular node in the tree. The effect gets rendered, but does not get displayed.
      below is the sampling of the jsf code. I have two rich:effects one on the event onclick which works ... but I need a second effect
      that needs to be triggered on the event sa.nodeEvent==true after it is rendered I would like the following code to work but it doesnt.
      the second effect does not highlight the event-fired node. Can I use an El.Expression for the event of rich:effect ?

      <rich:tree id="saTree" style="width:300px" switchType="ajax" >
      <rich:recursiveTreeNodesAdaptor id ="recSaTree" roots="#{saBean.srcRoots}" var="sa" nodes="#{sa.roots}">
      <rich:treeNode id="saNode" icon="iconLeaf.gif" iconLeaf="iconLeaf.gif">
      <h:commandLink id="saName" action="#{sa.click}" value="#{sa.name}" immediate="true"/>
      <rich:effect id="clickEffect" event="onclick" type="Highlight" params="duration:0.8" />
      <rich:effect id="evEff" name="eventEffect" rendered="#{sa.nodeEvent}" type="Highlight" params="duration:0.9" />
      </rich:treeNode>

      </rich:recursiveTreeNodesAdaptor>

      </rich:tree>

      <a4j:poll id="poll" interval="1000" enabled="#{saBean.srcRootsUpdated}" reRender="poll,saTree,evtb"/>

      Many thanks for your help in advance,
      Kind Regards,
      -- Brian

        • 1. Re: Richfaces limitation to display rich:effect programmatic
          nbelaevski

          Hello Brian,

          "event" can not be EL-expression.

          If you use "name" attribute - rich:effect creates client-side function that you can cell to trigger the effect. Here is how you can use this:

          <a4j:poll id="poll" interval="5000" enabled="true" reRender="saTree, effectsScript"/>
           <script type="text/javascript">window.effects = new Array();</script>
          
           <a4j:outputPanel id="effectsScript">
           <script type="text/javascript">
           while (effects.length > 0) {
           var effectFunc = effects.shift();
           effectFunc();
           }
           </script>
           </a4j:outputPanel>
          
          
           <rich:tree style="width:300px" value="#{library.data}" var="item" nodeFace="#{item.type}" id="saTree">
           <rich:treeNode id="artistNode" type="artist" iconLeaf="/images/tree/singer.gif" icon="/images/tree/singer.gif">
           <h:outputText value="#{item.name}" />
          
          
           <rich:effect id="clickEffect" event="onclick" type="Highlight" params="duration:0.8" />
           <rich:effect id="evEff" for="artistNode" name="effects[effects.length]" rendered="#{true}" type="Highlight" params="duration:0.9" />
           </rich:treeNode>
           </rich:tree>
           </h:form>
          

          It simply puts effects into array and then call them using external script (located in "effectsScript" component). Note that "for" attribute is necessary when "name" is used.

          • 2. Re: Richfaces limitation to display rich:effect programmatic
            nbelaevski

            Rerendering order can be unpredictable - https://jira.jboss.org/jira/browse/RF-7181, this should help:

            <a4j:outputPanel id="effectsScript">
             <script type="text/javascript">
             setTimeout(function() {
             while (effects.length > 0) {
             var effectFunc = effects.shift();
             effectFunc();
             }}, 0);
             </script>
             </a4j:outputPanel>


            • 3. Re: Richfaces limitation to display rich:effect programmatic
              brian13

              Hello Nick,
              Many thanks for the Solution !! that works ...

              Kind Regards,
              -- Brian