5 Replies Latest reply on Sep 8, 2011 10:53 AM by nathan dennis

    Get action outcome in EL (or even better javascript)?

    Christian Desserich Newbie

      Is there a way to get the action outcome in EL or javascript? Basically I want to say something like


      #{navigation.outcome == 'something' ? doSomething : doSomethingElse}
      



      or


      if (Seam.Component.getInstance("navigation").getOutcome() == 'something') {
           // do something
      }



      I want to reload another frame on the page with JQuery if certain actions were invoked. Thank you for any advice in advance!

        • 1. Re: Get action outcome in EL (or even better javascript)?
          Aldo Bonzi Novice

          I really don't get it. What does it stop you to set a variable in the right context at the end of your method execution and then read it with EL?

          • 2. Re: Get action outcome in EL (or even better javascript)?
            nathan dennis Expert

            best way to do this is with richfaces after the ajax submit, use oncomplete event


            
             <a:form id="editprofile_form" styleClass="edit">   
             <a:jsFunction name="rerenderTitles"
                 reRender="tlistPanel"
                 eventsQueue="peQueue">
                 <s:conversationId/>
             </a:jsFunction>  
            ...     
            
            



            call the java script from jquery. you can pass it action params too using a:param and assign it to a variable in a backing bean if you want to get fancy. i have done this many times.

            • 3. Re: Get action outcome in EL (or even better javascript)?
              Christian Desserich Newbie

              Thank you very much. Being new to Seam and having to deal with some legacy code, I am not always aware of the possibilities. The dumb thing is that I added some AJAX functionality to the page, but this particular function was using an h:commandLink. I was just trying to leave some of the already established stuff there and not have to add a backing variable specifically for tracking weather or not a certain action was called. So anyway, I just decided to make this functionality AJAX as well and use oncomplete as you suggested. However, I was not aware of the jsFunction tag so I learned something, thank you for that.


              I would still think that it would be cool if you could get to the action outcome in EL so that you could use it for conditionally rendering or processing elements, not just for managing page flow. Maybe I just haven't been doing it long enough to see the silliness/redundancy of that. Anyway, thanks for the advice.

              • 4. Re: Get action outcome in EL (or even better javascript)?
                nathan dennis Expert

                Christian Desserich wrote on Sep 08, 2011 09:44:



                I would still think that it would be cool if you could get to the action outcome in EL so that you could use it for conditionally rendering or processing elements, not just for managing page flow. Maybe I just haven't been doing it long enough to see the silliness/redundancy of that. Anyway, thanks for the advice.


                i said the same thing on this forum or the previous one before it got moved over 2 years ago. instead of meshing javascript with JSF EL per say, they came up with Seam Remoting. (calling backing beans directly from javascript). so while you cant seamlessly convert javascript to EL in a single line, you can use variables and functions from both at the same time by simply switching to strictly javascript and Seam.Remoting for some applications.


                i made heavy use of this approach a couple years ago when building a custom app that was essentially Gimp in a web browser. Worked really well actually and help to separate javascript/backing bean wizardry from the xml hell.

                • 5. Re: Get action outcome in EL (or even better javascript)?
                  nathan dennis Expert

                  one more thing i forgot to add. since you are implementing a jQuery function,, if you are using richfaces, check out the rich faces jQuery tag. you could probably avoid the extra step if you got creative with it.


                   <rich:jQuery  selector="#slideshow"  query="serialScroll({
                            items:'li',
                            prev:'#screen2 a.prev',
                            next:'#screen2 a.next',
                            offset:-230, 
                            start:1, 
                            duration:1200,
                            force:true,
                            stop:true,
                            lock:false,
                            cycle:false,
                            easing:'easeOutQuart',     
                            jump: true 
                       })" />
                  



                  actually i was just writing this when i saw you respond. X)