4 Replies Latest reply on Dec 8, 2008 4:58 AM by Nicolas Feybesse

    ExtendedDataTable don't reRender with dynamic columns

    Nicolas Feybesse Newbie

      ExtendedDataTable, after rerender, throws a NPE when a new Column appears in Rich:columns.

      Here is a sample test case :

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:a="http://richfaces.org/a4j"
       xmlns:c="http://java.sun.com/jstl/core"
       xmlns:rich="http://richfaces.org/rich">
      
      <body>
      <f:view>
       <h:form id="form">
       <rich:extendedDataTable value="#{testBean.rows}" var="row">
       <rich:columns value="#{testBean.columns}" var="column" index="ind">
       <f:facet name="header">
       <h:outputText value="#{column.name}" />
       </f:facet>
       <h:outputText value="#{row[ind]}" />
       </rich:columns>
       </rich:extendedDataTable>
       <a:commandButton value="Add column" action="#{testBean.addAColumn}" reRender="form" />
       </h:form>
      </f:view>
      </body>
      
      </html>
      


      And backBean code :
      @Name("testBean")
      @Scope(ScopeType.SESSION)
      public class Test {
       private static final Log log=Logging.getLog(Test.class);
      
       private List<Column> columns=Arrays.asList(new Column[]{new Column("Col1"),new Column("Col2")});
       private List<List<String>> rows=Arrays.asList(
       Arrays.asList(new String[]{"a","b"}),
       Arrays.asList(new String[]{"d","e"}));
      
      
       public List<Column> getColumns(){
       return columns;
       }
      
       public List<List<String>> getRows(){
       return rows;
       }
      
       public void addAColumn(){
       columns=Arrays.asList(new Column[]{new Column("Col1"),new Column("Col2"),new Column("Col3")});
       rows=Arrays.asList(Arrays.asList(new String[]{"a","b","c"}),Arrays.asList(new String[]{"d","e","f"}));
       }
      
       public class Column {
       private String name;
      
       public Column(String name){
       this.name=name;
       }
      
       public String getName(){
       return name;
       }
       }
      }
      


      I think the ExtendedDataTableState is not refreshed correctly when extendeddatatable is rerendered.

      Here is the exception :
      java.lang.NullPointerException
       at org.richfaces.component.ColumnsSizeState.getColumnSize(ExtendedDataTableState.java:299)
       at org.richfaces.component.ExtendedDataTableState.getColumnSize(ExtendedDataTableState.java:159)
       at org.richfaces.component.UIExtendedDataTable.getColumnSize(UIExtendedDataTable.java:183)
       at org.richfaces.renderkit.AbstractExtendedTableRenderer.encodeColumns(AbstractExtendedTableRenderer.java:130)
       at org.richfaces.renderkit.html.ExtendedDataTableRenderer.doEncodeBegin(ExtendedDataTableRenderer.java:301)
       at org.richfaces.renderkit.html.ExtendedDataTableRenderer.doEncodeBegin(ExtendedDataTableRenderer.java:236)
       at org.ajax4jsf.renderkit.RendererBase.encodeBegin(RendererBase.java:101)
       at org.richfaces.renderkit.AbstractExtendedTableRenderer.encodeBegin(AbstractExtendedTableRenderer.java:1346)
       at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
       at javax.faces.component.UIData.encodeBegin(UIData.java:962)
       at org.ajax4jsf.component.UIDataAdaptor.encodeBegin(UIDataAdaptor.java:1220)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:934)
       at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:124)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxChildren(AjaxChildrenRenderer.java:67)
       at org.ajax4jsf.renderkit.AjaxChildrenRenderer.encodeAjaxComponent(AjaxChildrenRenderer.java:115)
       at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:123)
       at org.ajax4jsf.component.AjaxViewRoot.encodeAjax(AjaxViewRoot.java:677)
       at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:548)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:197)
       at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
       at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
       at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
       at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
       at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:195)
       at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:159)
       at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141)
       at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90)
       at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:406)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
       at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:38)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:307)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:423)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:550)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:51)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
       at java.lang.Thread.run(Thread.java:619)
      


      Thanks to have a look to this issue.