2 Replies Latest reply on Nov 13, 2007 8:44 AM by bruno.arruda

    Conditional rich:effect

      Hi ppl,

      I need some help, I have this commandlink with a effect to show a panel with the effect "Apear". :

      
       <a4j:commandLink action="{testmb.test}" value="Show">
       <rich:effect event="oncomplete" targetId="test" type="Appear" />
       </a4j:commandLink>
      
       <rich:panel id="test" style="display:none;">
       Text test text test
       </rich:panel>
      
      


      On testmb test() I do some logic, and I want the effect only executes if a certain condition is met. I tried somethings but I couldn´t do it, do you guys have any ideas ?

      Thanks in advance,

      Best Regards


        • 1. Re: Conditional rich:effect

          you can use effect as a function by defining the 'name' attribute instead of attaching by 'event' attribute. After that you can invoke this function from 'oncomplete' of the a4j:commandLink explicitly only if the conditions are met.

          Probably, the other way is using callback function of the effect itself and invoke this.event.cancel(), but I did not try it by myself yet.

          • 2. Re: Conditional rich:effect

            thanks Sergey.

            I was able to do it, here comes the code for those with this interesting:

            
             <a4j:commandLink action="#{test.changeCompleted}" oncomplete="if (#{test.completed}==true) showDiv();" value="Show4444" />
            
             <input type="button" onclick="showDiv()" value="Show" />
            
             <rich:effect name="showDiv" for="test" type="Appear" />