4 Replies Latest reply on Oct 30, 2008 7:37 PM by nbelaevski

    how to programmatically invoke rerender

    gsegura

      Hello,
      I need to be able to refresh (reRender) a given datatable component via javascript, I wonder how could this be done.

      I cannot use commandButton or similar because this must be done without user interaction. Also this may o may not occur so no periodic technique (a4j:push) is useful.

      The condition which triggers the reRendering occurs (if at all) in client side.

      hope someone can provide any help

      best regards

        • 1. Re: how to programmatically invoke rerender
          gizola

          One thing you could try is:

          place any not visible component somewhere on the form (eg an empty outputLabel) wich has any javascript event (onchange, onblur, anything).

          add an a4j:support which fires on the event your choice, and set reRender the components with it as you wish.

          So when you want to reRender the components, just call the javascript event function of the component from javascript. The ajax event will be fired, and then the components will be reRendered.

          javascript:
          
          function fireaction(id)
          {
           var obj = document.getElementById(id);
           obj.onblur();
          }
          
          xhtml:
          
          <h:outputLabel id="hidd" value="">
           <a4j:support event="onblur" reRender="comp">
           </a4j:support>
          </h:outputLabel>
          
          


          Try it, it seems to work, I tried it with action not with reRender, but the action method was called.

          Gizola

          • 2. Re: how to programmatically invoke rerender
            gizola

            Ohh, to call it:

            fireaction('form:hidd');

            So you have to call the onblur event on the 'hidd' component, not on the a4j:support component!

            Gizola

            • 3. Re: how to programmatically invoke rerender
              gsegura

              of course! nice simple trick.
              thanks!

              • 4. Re: how to programmatically invoke rerender
                nbelaevski

                Hi,

                Use a4j:jsFunction.