4 Replies Latest reply on Jun 7, 2007 3:29 PM by Eric Jung

    h:dataTable reRender

    Eric Jung Newbie

      I have the following code:

      <h:inputText .../>
      <a4j:commandButton value="Search" action="#{myBean.search}" reRender="p1"/>
      
      <h:panelGroup id="p1" rendered="#{!empty(myBean.dataObjects)}">
       <h:dataTable value="#{myBean.dataObjects} ... >
       ...
       </h:dataTable>
      </h:panelGroup>

      When the user clicks the commandButton, the dataTable is succesfully updated via ajax. However, if the myBean.dataObjects is empty, the dataTable still displays the old data. Instead, it shouldn't be rendered at all. If I change a4j:commandButton to h:commandButton, this works as expected. What am I doing wrong?

      Thanks for any help,
      grimholtz

        • 1. Re: h:dataTable reRender
          Sergey Smirnov Master

          It works like expected.
          When "rendered" becomes false, the Ajax response contains nothing about the panel. So, nothing updated on the client then.

          Try to use a4j:outputPanel layout="none". See http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052203#4052203 for info how it works.

          • 2. Re: h:dataTable reRender
            Eric Jung Newbie

            Hi Sergey, thanks for the explanation. I'm trying with a4j:outputPanel (with id, without id, with layout=none with no layout attribute), but always get a JSP compiler exception. Any ideas?

            2007-06-07 14:17:16,807 DEBUG [org.ajax4jsf.framework.renderer.AjaxPhaseListener] (TP-Processor12:) Process after phase INVOKE_APPLICATION(5)
            2007-06-07 14:17:16,807 DEBUG [org.ajax4jsf.framework.renderer.AjaxPhaseListener] (TP-Processor12:) Process before phase RENDER_RESPONSE(6)
            2007-06-07 14:17:16,807 DEBUG [org.ajax4jsf.framework.renderer.AjaxPhaseListener] (TP-Processor12:) PhaseListener enter Before RenderView Phase with ViewId /StudySelector.jsp and RenderKitId HTML_BASIC
            2007-06-07 14:17:17,409 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/pat].[jsp]] (TP-Processor12:) Servlet.service() for servlet jsp threw exception
            org.apache.jasper.JasperException: Unable to compile class for JSP
            
            Generated servlet error:
            Syntax error, insert "while ( Expression ) ;" to complete DoStatement
            
            Generated servlet error:
            Syntax error, insert "Finally" to complete TryStatement
            
            Generated servlet error:
            Syntax error on token "}", { expected after this token
            
            Generated servlet error:
            _jspx_th_f_view_0 cannot be resolved
            
            Generated servlet error:
            Syntax error on token "catch", Identifier expected
            
            Generated servlet error:
            out cannot be resolved
            
            Generated servlet error:
            _jspx_out cannot be resolved
            
            Generated servlet error:
            out cannot be resolved
            
            Generated servlet error:
            out cannot be resolved
            
            Generated servlet error:
            out cannot be resolved
            
            Generated servlet error:
            _jspx_page_context cannot be resolved
            
            Generated servlet error:
            _jspx_page_context cannot be resolved
            
            Generated servlet error:
            Syntax error on token "finally", delete this token
            
            Generated servlet error:
            _jspxFactory cannot be resolved
            
            Generated servlet error:
            _jspxFactory cannot be resolved
            
            Generated servlet error:
            _jspx_page_context cannot be resolved
            
            Generated servlet error:
            Syntax error on token "}", delete this token
            
            
             at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
             at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
             at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
             at org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
             at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
             at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
             at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
             at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
             at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
             at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
             at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
             at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
             at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
             at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
             at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:416)
             at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
             at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
             at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:229)
            ...


            • 3. Re: h:dataTable reRender
              Sergey Smirnov Master

              looks not good.

              What if you move rendered attribute to the table itself.

              Like:

              <h:inputText .../>
              <a4j:commandButton value="Search" action="#{myBean.search}" reRender="p1"/>
              
              <h:panelGroup id="p1">
               <h:dataTable value="#{myBean.dataObjects} rendered="#{!empty(myBean.dataObjects)}" ... >
               ...
               </h:dataTable>
              </h:panelGroup>


              • 4. Re: h:dataTable reRender
                Eric Jung Newbie

                Interestingly, the JSP compiler error was due to this comment in the JSP:

                <%/* Using aj4:outputPanel because of http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052232 /*%>

                Removing it gets rid of the compiler error. The dataTable still isn't working as I'd like, but I'm not finished yet. Thanks, Sergey.