5 Replies Latest reply on Feb 12, 2009 8:05 PM by nbelaevski

    exception when nesting rich:dataTables

    ultrapod

      i'm not sure if this is something i'm doing wrong, or if this is an actual bug. i'm trying to nest two rich:dataTables, one of which has a rich:datascroller attached to it. after a couple of clicks on the scroller my application crashes with an exception.

      my jsp page:

      <%@ page contentType="text/html; charset=UTF-8" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
      
      <f:view>
       <html>
       <body>
      
       <a4j:form id="testbed_form">
      
       <rich:dataTable id = "outer_table"
       rows = "10"
       value = "#{TestbedBean.outerTableRows}"
       var = "outer_row">
      
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Column 1"/>
       </f:facet>
       <h:outputText value="#{outer_row}"/>
       </rich:column>
      
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Column 2"/>
       </f:facet>
       <h:outputText value="#{outer_row}"/>
       </rich:column>
      
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Column 3"/>
       </f:facet>
       <h:outputText value="#{outer_row}"/>
       </rich:column>
      
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Column 4"/>
       </f:facet>
       <h:outputText value="#{outer_row}"/>
       </rich:column>
      
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Column 5"/>
       </f:facet>
       <h:outputText value="#{outer_row}"/>
       </rich:column>
      
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Column 6"/>
       </f:facet>
       <h:outputText value="#{outer_row}"/>
       </rich:column>
      
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Column 7"/>
       </f:facet>
       <rich:dataTable id = "inner_table"
       rows = "0"
       value = "#{TestbedBean.innerTableRows}"
       var = "inner_row">
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Inner Column 1"/>
       </f:facet>
       <h:outputText value="#{inner_row}"/>
       </rich:column>
      
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Inner Column 2"/>
       </f:facet>
       <h:outputText value="#{inner_row}"/>
       </rich:column>
       </rich:dataTable>
       </rich:column>
      
       </rich:dataTable>
       <rich:datascroller id="outer_scroller"
       for="outer_table"
       maxPages="10">
       </rich:datascroller>
      
       <rich:messages globalOnly="true"/>
       </a4j:form>
      
       </body>
       </html>
      </f:view>
      



      my backing bean, pretty simple:

      import java.util.ArrayList;
      import java.util.List;
      
      public class TestbedBean
      {
       public List getOuterTableRows()
       {
       ArrayList<String> retval = new ArrayList<String>();
      
       for(int i=1; i<=30; i++)
       {
       retval.add(Integer.toString(i));
       }
      
       return retval;
       }
      
       public List getInnerTableRows()
       {
       ArrayList<String> retval = new ArrayList<String>();
       retval.add("inner row");
       return retval;
       }
      
      }
      



      the exception (some stuff removed):

      java.lang.StringIndexOutOfBoundsException: srcBegin > srcEnd
       at java.lang.AbstractStringBuilder.getChars(AbstractStringBuilder.java:330)
       at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.flushAttributes(HtmlResponseWriter.java:981)
       at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.endElement(HtmlResponseWriter.java:489)
       at org.ajax4jsf.renderkit.AjaxRendererUtils.encodeAreas(AjaxRendererUtils.java:717)
       at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeAjax(AjaxContainerRenderer.java:125)
       at org.ajax4jsf.component.AjaxViewRoot.encodeAjax(AjaxViewRoot.java:641)
       at org.ajax4jsf.component.AjaxViewRoot.encodeChildren(AjaxViewRoot.java:512)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
       at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:271)
       at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:202)
       at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
       at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
       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.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:147)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:256)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:362)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:488)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      ...
      



      1. this problem goes away if i use an h:dataTable as the inner table. this is a viable solution for me, but i'd really prefer to be able to use two rich:dataTables.

      2. this seems unrelated to my web.xml configuration. i've stripped out any richfaces parameters in my web.xml and it seems to have no effect.

      3. the page renders fine initially; it only crashes when i try to scroll through the outer table. oddly enough, it will sometimes allow me to scroll once, but not a second time.

      i'm using JBoss 4.2.2 GA, JSF RI (Mojarra) 1.2_08-b06-FCS, RichFaces 3.2.0.SR1, and Firefox 2.0.0.14.

      i'm pretty stumped by this and i suspect that i'm doing something wrong, but i have no idea what that would be. pretty much everything else in my application works great, until i try nesting rich:dataTables. any and all suggestions would be greatly appreciated. thanks!

        • 1. Re: exception when nesting rich:dataTables
          ilya_shaikovsky

          try to use rich:subtable instead of dataTable as nested to the main table.

          • 2. Re: exception when nesting rich:dataTables
            ultrapod

            ah, now i see. that makes a certain amount of sense; i thought i was missing something obvious. i suppose the good news is that i no longer have the scrolling exception, but the bad news is that i have no idea how to get the subtable to behave in the way i want it to... i'll save my subtable questions for a different thread, though. thanks very much for your prompt help!

            • 3. Re: exception when nesting rich:dataTables
              ultrapod

              ilya, can you explain to me why the inability to nest rich:datatables directly is not considered a bug? i accept that using a rich:subtable might be the preferred "standard" method of displaying master-detail relationships, but i can think of a number of use cases where it would be preferable to have the ability to nest rich:datatables directly. furthermore, the JSF RI analogue (h:datatable) allows nesting, and in fact, you can nest an h:datatable inside a rich:datatable.

              • 4. Re: exception when nesting rich:dataTables

                Hi Ilya,

                I was hoping you could answer Ultrapod's question. I have a use case that very much needs nested rich:dataTables, but the sorting/filtering/reRendering of the nested tables does not work. Is this a bug that will perhaps be fixed, or is it not even being addressed as a bug? And, if so, why not?; since, as Ultrapod says, the JSF spec allows for nested h:dataTables. Thanks.

                • 5. Re: exception when nesting rich:dataTables
                  nbelaevski

                  Hello,

                  1.2_08 Mojarra had issue with response writer causing illegal attributes write. Can you please try with 1.2_09?