8 Replies Latest reply on Sep 20, 2007 10:05 AM by Ilya Shaikovsky

    PanelGrid not being reRendered

    Bruno Arruda Newbie

      Hi ppl,

      Thas going to be a hard one. My application is very customized, so I will post the details when there are requests for them, othersiwe this topic would be very confusing.

      My problem is, i got a page that is a subview of a master one, inside it i have this code:

      <a4j:region id="viewSurveyRegion1">
      
      <a4j:outputPanel ajaxRendered="true" id="viewSurveyOutputPanel1">
      
      <a4j:form id="viewSurveyForm1" ajaxSubmit="true" reRender="viewSurveyPanelGrid1">
      
       <h:panelGrid id="viewSurveyPanelGrid1" columns="1" binding="#{survey.previewPage}" >
       </h:panelGrid>
      
       <a4j:commandLink reRender="viewSurveyPanelGrid1" action="#{survey.previousViewPage}"
       value="#{msg.surveyCommandLink1}" id="viewSurveyCommandLink1" rendered="#{survey.previousPageRender}" />
       <a4j:commandLink reRender="viewSurveyPanelGrid1" action="#{survey.nextViewPage}"
       value="#{msg.surveyCommandLink2}" id="viewSurveyCommandLink2" rendered="#{survey.nextPageRender}" />
      
      </a4j:form>
      
      </a4j:outputPanel>
      
      </a4j:region>
      
      


      Ok, when i submit to the Managedbean and changes the values on the page everything is reRendered nicely, except for the panelgrid viewSurveyPanelGrid1, i already debuged it and Im´m sure the code generated HTMLGrid at the ManagedBean is beeing changed, so the problem is on the reRendering, as you can see i tried almost everything to make it reRenders, but no luck.

      Please if anyone could help me here it would be nice cause it is very important to me.

      Let me know if you need more details.

      Best Regards.


        • 1. Re: PanelGrid not being reRendered
          Sergey Smirnov Master

          First off, do not use ajaxSubmit="true" on the form when you work with ajax buttons inside this form. It is just does not make any sense.
          See: http://livedemo.exadel.com/richfaces-demo/richfaces/form.jsf?c=form for the real purpose of the ajaxSubmit attribute

          We think that the problem you have is outside from the snippet you provide.

          Are you sure, the action on the button are invoked?
          What is inside of the panelGrid (inputs or just pure text)?

          Add <a4j:log hotkey="M"/>
          After the page reloading, when you press Ctrl-Shift-M, the popup will show the log. Open the log and click the button.
          What the log says about viewSurveyPanelGrid1 ?

          • 2. Re: PanelGrid not being reRendered
            Bruno Arruda Newbie

            Once again thanks Sergey for your cooperation and help:

            Ok, in parts:

            1-About the ajaxSubmit="true" it was more a desperate action, i was not using originally heheh

            2-About the log, don´t know why but with the hotkey it didnt work, so I used: <a4j:log popup="false" level="ALL" ></a4j:log>. And it shows nothing about viewSurveyPanelGrid1 , strange...

            3- about the outside part of the code: That its what I was affraid so, ok, after removing links and content thats not regarding this problem, here is my "master" page, the one that contents the other one already snipped:

            
            <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
            <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
            <%@taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
            <%@taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
            <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
            <%@taglib uri="http://testonline.com.br/taglibs/application" prefix="app"%>
            
            <html>
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
            </head>
            <body>
            
            <f:view>
             <a4j:region id="stat1">
             <a4j:outputPanel ajaxRendered="true" id="mainCustomerOutputPanel1">
             <h:outputText id="mainCustomerOutpuText1" value="Menu" />
             <h:form id="mainCustomerForm1">
             <f:loadBundle basename="br.com.testonline.web.resource.htmlMessages" var="msg" />
             <h:panelGrid id="mainCustomerPanelGrid1">
             <h:panelGroup id="mainCustomerPanelGroup1">
             <a4j:commandButton value="Sair"
             action="#{mainCustomer.logoffForward}" id="mainCustomerCommandButton2">
             </a4j:commandButton>
             <a4j:commandButton value="Gerenciar Provas"
             action="#{mainCustomer.manageSurveyForward}" id="mainCustomerCommandButton3">
             </a4j:commandButton>
             </h:panelGroup>
             </h:panelGrid>
             </h:form>
            
             <h:panelGrid id="mainPanel2">
             <h:panelGroup id="mainCustomerPanelGroup2">
             <f:subview id="includedPage">
             <a4j:include viewId="#{mainCustomer.page}" id="a4jInclude1" />
             </f:subview>
             </h:panelGroup>
             </h:panelGrid>
             <h:outputText id="mainCustomerOutpuText2" value="Status Bar:" />
             <h:messages />
            
            
             <a4j:status for="stat1">
             <f:facet name="start">
             <f:verbatim>
             <div id='siteLoader' style="position:absolute;top:0px;left:0px;width: 100%; height: 100%;">
             <div id='siteDetailLoader'>
             Selecionar.com.br
             </div>
             <div id='loadImg'>
             <img src='/TestOnline/pages/general/images/logo_selecionar.jpg' border='0'>
             <br>
             <center>
             Carregando...
             <img src='/TestOnline/pages/general/images/loadinfo.gif' border='0'>
             </center>
             <p> </p>
             </div>
             <div id='loadText'>
             Por favor, aguarde ...
             </div>
             </div>
             </f:verbatim>
             </f:facet>
             </a4j:status>
            
             </a4j:outputPanel>
             </a4j:region>
            </f:view>
            </html>
            
            



            The other page is inserted in this one on "a4jInclude1" component by a managedBean(#{mainCustomer.page}). We did that way so our application does not have any refreshing at all.

            Please let me know if it is clear, or you need any other information, thanks very much again

            • 3. Re: PanelGrid not being reRendered
              Sergey Smirnov Master

              I see one more desperate action on your side - you wrap the whole page content into the a4j:outputPanel ajaxRendered="true". So, you try to replace the whole page. Do no see the reason, why you use ajax in this case.

              Actually, I am lost now with your code.

              • 4. Re: PanelGrid not being reRendered
                Bruno Arruda Newbie

                Ok thanks again.

                About the ajaxRendered you are correct, we were using the reRender as you will see it bellow.

                Here comes the full process:

                mainCustomer.jsp is the main page, that uses the MainCustomerMB to manage the include content ("a4jInclude1"). When the user clicks on the button mainCustomerCommandButton3 for example, it calls the method manageSurveyForward on MainCustomerMB to set the page content, than it reRenders the mainPanel2 to show the new content.

                on surveyList.jsp(which is a content inside mainCustomer.jsp) i have a panelGrid that is generated on another managedBean by code. When the user clicks on the button previousViewPage for example, it changes the grid content and should be reRendered.

                Everything that is changed on surveyList.jsp is reRendered nicely, except for the panelGrid: viewSurveyPanelGrid1.

                More clear now? here comes the codes:


                MainCustomerMB.java

                
                public class MainCustomerMB
                {
                 //default page
                 private String page = "/pages/customer/welcomeCustomer.jsp";
                
                 public void manageSurveyForward( )
                 {
                 this.page = "/pages/customer/survey/surveyList.jsp";
                 }
                
                 public String getPage( )
                 {
                 return page;
                 }
                
                 public void setPage( String page )
                 {
                 this.page = page;
                 }
                }
                
                



                mainCustomer.jsp
                
                <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
                <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
                <%@taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
                <%@taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
                <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
                <%@taglib uri="http://testonline.com.br/taglibs/application" prefix="app"%>
                
                <html>
                <head>
                <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
                </head>
                <body>
                
                <f:view>
                 <a4j:region id="stat1">
                 <h:form id="mainCustomerForm1">
                 <h:panelGrid id="mainCustomerPanelGrid1">
                 <h:panelGroup id="mainCustomerPanelGroup1">
                 <a4j:commandButton value="Gerenciar Provas"
                 action="#{mainCustomer.manageSurveyForward}" id="mainCustomerCommandButton3" reRender="mainPanel2">
                 </a4j:commandButton>
                 </h:panelGroup>
                 </h:panelGrid>
                 </h:form>
                
                 <h:panelGrid id="mainPanel2">
                 <h:panelGroup id="mainCustomerPanelGroup2">
                 <f:subview id="includedPage">
                 <a4j:include viewId="#{mainCustomer.page}" id="a4jInclude1" />
                 </f:subview>
                 </h:panelGroup>
                 </h:panelGrid>
                 </a4j:region>
                </f:view>
                </html>
                
                



                surveyList.jsp
                
                <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
                <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
                <%@taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
                <%@taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
                <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
                
                <f:loadBundle basename="br.com.testonline.web.resource.htmlMessages" var="msg" />
                
                <a4j:region id="viewSurveyRegion1">
                 <a4j:outputPanel ajaxRendered="true" id="viewSurveyOutputPanel1">
                 <a4j:form id="viewSurveyForm1" reRender="viewSurveyPanelGrid1">
                
                 <h:panelGrid id="viewSurveyPanelGrid1" columns="1" binding="#{survey.page}" >
                 </h:panelGrid>
                
                 <a4j:commandLink reRender="viewSurveyPanelGrid1" action="#{survey.previousViewPage}" value="#{msg.surveyCommandLink1}" id="viewSurveyCommandLink1" rendered="#{survey.previousPageRender}" />
                 <h:outputText id="viewSurveyOutputText1" value="#{survey.title}"></h:outputText>
                 <a4j:commandLink reRender="viewSurveyPanelGrid1" action="#{survey.nextViewPage}" value="#{msg.surveyCommandLink2}" id="viewSurveyCommandLink2" rendered="#{survey.nextPageRender}" />
                
                 <a4j:log popup="false" level="ALL" ></a4j:log>
                
                 </a4j:form>
                 </a4j:outputPanel>
                </a4j:region>
                
                


                • 5. Re: PanelGrid not being reRendered
                  Bruno Arruda Newbie

                  Ok,
                  After removing the region from mainCustomer.jsp

                  and

                  removing the region and <a4j:outputPanel ajaxRendered="true" id="viewSurveyOutputPanel1"> from surveyList i got something on a4j:log:

                  
                  debug[17:01:16,109]: Attempt to update part of page for Id: includedPage:a4jInclude1:viewSurveyForm1:viewSurveyPanelGrid1
                  debug[17:01:16,125]: call selectSingleNode for id= includedPage:a4jInclude1:viewSurveyForm1:viewSurveyPanelGrid1
                  debug[17:01:16,125]: Replace content of node by outerHTML()
                  error[17:01:16,125]: Error to clear node content by innerHTML
                  debug[17:01:16,125]: search for elements by name 'script' in element table
                  debug[17:01:16,125]: selectNodes found 0
                  debug[17:01:16,125]: Scripts in updated part count : 0
                  debug[17:01:16,125]: Update part of page for Id: includedPage:a4jInclude1:viewSurveyForm1:viewSurveyPanelGrid1 successful
                  
                  


                  • 6. Re: PanelGrid not being reRendered
                    Ilya Shaikovsky Master

                    So reRendering is succesfull as it shown in log. Elements are found and replaced. If the values are wrong? If so check please in debuger how #{survey.page} is updated during request.

                    • 7. Re: PanelGrid not being reRendered
                      Bruno Arruda Newbie

                      Hi,

                      thanks all for trying to help

                      Ilya about your questions,

                      the problem is not the value, but it seems to not beeing reRendering... but only this panel grid, i tried a few moves like placing the panelgrid outside the form, reRendering multiple panels, but everything works except for this panelgrid.

                      I can see this error:

                      error[17:01:16,125]: Error to clear node content by innerHTML

                      wouldnt that be the cause?

                      Ilya said:
                      If so check please in debuger how #{survey.page} is updated during request.

                      I really dont know excatly what to look and not sure how...


                      thanks again

                      • 8. Re: PanelGrid not being reRendered
                        Ilya Shaikovsky Master

                        By the way what is a scope of #{survey} bean?

                        Ok... Lets start again. Think - will be more clear to create basic example from your code and paste its full code somewhere. Also it'll be helpfull to know precise environment info.

                        After will be simple to just copy paste this and check.