4 Replies Latest reply on Jan 31, 2012 3:10 PM by true_mykola

    a4j:jsFunction rerender doesn't work

    true_mykola

           Hi!  I have a problem of making dynamic context menu so I need to load pages with needed modal panels dynamically which i was hoping to achieve with a4j:include as ui:include can't be rerendered. But i've faced a strange problem with a4j:jsFunction: it doesn't want to rerender elements if the page with this function is included with a4j:include (with ui:include everything works fine). Why does it happen and how to fix it?

           Here's how i include pages:

      <a4j:include id="invoicesSubview" viewId="#{MbContextMenu.panelViewId}">
          <ui:param name="viewId" value="invoicesSubview"/>
          <ui:param name="viewIdColon" value="invoicesSubview:"/>
          <ui:param name="fromCtx" value="true"/>
      </a4j:include>
      

           And here's a part of page with panel:

      <h:form id="rptInitForm">
          <a4j:jsFunction action="#{MbReportsContext.initializeModalPanel}" 
                  name="initializeReportPanel#{viewId}" reRender="#{viewIdColon}reportRunForm">
          </a4j:jsFunction>
      </h:form>
      
      <rich:modalPanel id="reportRunPanel"  autosized="true" minWidth="300" minHeight="50"
          onbeforeshow="if (#{empty fromCtx ? false : true}) initializeReportPanel#{viewId}()">
           <f:facet name="header">
               <h:outputText value="#{lblRpt.run_report}"/>
           </f:facet>            
           <h:form id="reportRunForm">
      

       

      So, the function ("initializeReportPanel#{viewId}") itself is called, bean's method ("#{MbReportsContext.initializeModalPanel}") is called too, but the form isn't rerendered although its id is formed correctly. All the same code when called from the same page but included with ui:include (inside f:subview) works fine. Is it some a4j:include issue or may be i do something wrong?

       

      I'm using JSF 1.2 and Richfaces 3.3.3

        • 1. Re: a4j:jsFunction rerender doesn't work
          mcmurdosound

          do not rerender forms. You should add an a4j:outputPanel or a h:panelGroup to the the form and reRender this one instead:

           

          <h:form id="#{viewId}Form">

          <a4j:outputPanel id="refreshMe">

          <script>

          console.log("i was rerendered!");

          </script>

              <a4j:jsFunction action="#{MbReportsContext.initializeModalPanel}"
                      name="initializeReportPanel#{viewId}" reRender="#{viewIdColon}#{viewId}Form:refreshMe">

              </a4j:jsFunction>

          ...

           

          the script tag should give a hint, if the part of the page is actually rerendered.

          • 2. Re: a4j:jsFunction rerender doesn't work
            true_mykola

            Nope, it didn't help.

            • 3. Re: a4j:jsFunction rerender doesn't work
              mcmurdosound

              sorry, my fault. I've got mixed up with your forms ;-) I thought, the jsFunction would reRender its surrounding form but it reRenders the modal panels form instead!

               

              Then try:

              </f:facet>           
                   <h:form id="reportRunForm">

                          <a4j:outputPanel id="refreshMe">...

               

              and reRender the panel:

              reRender="#{viewIdColon}reportRunForm:refreshMe"

              • 4. Re: a4j:jsFunction rerender doesn't work
                true_mykola

                well, of course i didn't just copy-paste i put correct id into reRender parameter and it didn't work