4 Replies Latest reply on Mar 12, 2010 1:20 AM by Harut Sargsyan

    How to reRender a component via a Javascript function???

    Peter Len Apprentice

      Hello,

       

      I am wondering if it is possible to reRender a component via a javascript call rather than through the reRender attribute on an a4j component.  As an example, I do something in the client that requires me to use SEAM Remoting.  When my remoting javascript callback function is called, I would like to reRender a rich:tree.  I have gotten this behavior to work currently through the following:

       

      1) Create a hidden a4j commandButton that simply does a reRender of the tree.

      2) When my remoting javascript callback function is called, I use javascript to "click" the hidden commandButton.

       

      This works, at least for now, but this seems to be a kludge and not the proper way of doing it.  Is there is a proper way of doing it or if the SEAM/JSF/RichFaces framework does not have a way to get this behavior?  I am hoping that there is a way to get ahold of the component via javascript and then call something like rerender() on it.

       

      Thanks for any thoughts - Peter

        • 1. Re: How to reRender a component via a Javascript function???
          Harut Sargsyan Apprentice
          Hi, You can use a4j:jsFunction component, and do reRender in it...
          • 2. Re: How to reRender a component via a Javascript function???
            Peter Len Apprentice

            Harut,

             

            Thanks for the response.  The jsFunction won't help in this scenario, however.  The jsFunction essentially behaves just like the commandButton does and the reason that I have to use SEAM remoting instead of the a4j commandButton is that the data that I need to send back will not be able to be sent down via an actionparam.  So while the jsFunction can have a reRender, it is basically the same problem that I have as to why I can't use the reRender with the commandButton and thus need to find a way to call a reRender from my seam remoting callback function.

             

            As I am writing this, I am wondering if it is possible to define a jsFunction which will act as a seam remoting callback function.  The test will be to see if you can pass the seam remoting response object to the jsFunction (acting as the callback function) via the jsFunction's actionparam.  If that will work, then I guess using a jsFunction could be the answer.  If not, then I am back to having to figure out a way to do a rerender from a generic javascript function.

             

            Thanks - Peter

            • 3. Re: How to reRender a component via a Javascript function???
              Peter Len Apprentice

              After looking at the jsFunction, I found that I could use it easier than I anticipated (my previous reply).  I simply declared:

               

              <a:jsFunction name=

              "rerenderDataTree" reRender="ftree" limitToList="true" />

               

              and then I have my seam remoting callback function call the rerenderDataTree function.  This should work great.

               

              Thanks - Peter

              • 4. Re: How to reRender a component via a Javascript function???
                Harut Sargsyan Apprentice

                Hi Peter,

                     I ment exactly the same way you mentioned in your last reply. Glad to hear that it works fine for your functionality

                Regards, Harut.