3 Replies Latest reply on Jan 10, 2013 10:35 AM by fjkjava

    Re-rendering a component is executing the page load action.

    fjkjava

      Hi All,

       

      I recently migrated our application from Jboss4.2/Seam 2.0/Richfaces 3.3 to Jboss 7/Seam 2.3/Richfaces 4.2 after that I found that most of the ajax requests are taking more time to finish. I am trying to figure out why this is happening. I did some debugging and found the following scenario.

      I have a SelectOneMenu and a Text are in one page, value of Text area is mandatory based on the value of SelectOneMenu so I  re-render Text area on onchage event of SelectOneMenu.

       

       

      <td style="width: 25%">
      <a:region>
                      <s:decorate id="statusDecoration" template="/layout/edit.xhtml">
                  <ui:define name="label"> Status</ui:define>
      <h:selectOneMenu id="status" required="true" value="#{editManager.statusId}">
                                  <f:selectItems value="#{dBUtil.getStatuses())}" />
                                  <a:ajax event="change" render="commentsDecoration"/>
                            </h:selectOneMenu> 
                      </s:decorate>
            </a:region>
      </td>
      <td>
            <s:decorate id="commentsDecoration" template="/layout/edit.xhtml"      rendered="#{editManager.type=='Testing'}">
      <ui:define name="label"> Comments</ui:define>                
      
      <h:inputTextarea id="comments    required="#{(editManager.statusId==5 or editManager.statusId ==6) 
                      rows="2"
                      cols="50"
                      value="#{editManager.comments}"/>     
            </s:decorate>
      </td>
      

       

      The re-render take 3-8 second to finish. When I look at log I found that the action specified in page.xml (<action execute="#{editManager.wire}"/>) is executing before the re-render. I think the ajax request should not execute the wire method. Can somebody say why this is executing?

       

      Thanks

        • 1. Re: Re-rendering a component is executing the page load action.
          healeyb

          I'm not a Seam user myself (maybe Brian Leathem could comment on this) however the JSF preRenderView event on which this

          Seam action might be based, certainly does execute for an ajax request. I use an abstract class from which all my backing beans

          inherit containing a function like this:

           

          public boolean isAjaxRequest() {

              return FacesContext.getCurrentInstance().getPartialViewContext().isAjaxRequest();

          }

           

          and then in my page load action method I check the condition and process accordingly, there is typically processing that you only

          want to execute on a full page load. Whether this will work in your situation should be easily testable.

           

          I was initially surprised that it works like this, but there it is. Presumably the change is caused by upgrading from JSF 1 - JSF 2,

          and using the built in JSF 2 ajax functionality instead of a4j.

           

          Regards,

          Brendan.

          • 2. Re: Re-rendering a component is executing the page load action.
            omonaija

            This is similar to a Seam 2.3 bug addressed in https://issues.jboss.org/browse/JBSEAM-4976

             

            One workaround is to pass the conversation id as a hidden value. Add this somewhere in your h:form: <input type="hidden" name="cid" value="#{conversation.id}" />

             

            Another workaround is to disable partial state saving. Add this to your web.xml file:

             

            <context-param>

               <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>

               <param-value>false</param-value>

            </context-param>

            • 3. Re: Re-rendering a component is executing the page load action.
              fjkjava

              Thanks Brendan and Omo, I will try your suggestions.