Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-11090

rich:collapsibleSubTable cannot be nested

    Details

      Description

      When <rich:collapsibleSubTable /> s are nested, the following error occurs:

      This page contains the following errors:
      error on line 202 at column 74: Opening and ending tag mismatch: tbody line 0 and tr
      Below is a rendering of the page up to the first error.

      The page is rendered up to the nested <rich:collapsibleSubTable />.

      This error happens b/c nested sub tables render an extra </tr> element after the nested subtable row.

      I was able to work around the problem by making a small tweak to CollapsibleSubTableRenderer. The lines I added or changes are marked with "// fix line" comment.

      FixedCollapsibleSubTableRenderer.java

       
      /**
       * Allows nested subTables to be rendered properly
       */
      @ResourceDependencies({
          @ResourceDependency(name = "jquery.js"),
          @ResourceDependency(name = "richfaces.js"),
          @ResourceDependency(library="org.richfaces", name = "collapsible-subtable.ecss"),
          @ResourceDependency(library="org.richfaces", name = "collapsible-subtable.js")
      })
      public class FixedCollapsibleSubTableRenderer extends CollapsibleSubTableRenderer {
      	
      	@Override
      	public void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase holder) throws IOException {
              RowHolder rowHolder = (RowHolder)holder;
              Row row = rowHolder.getRow();
              putRowStylesIntoContext(facesContext, rowHolder);    
              rowHolder.setRowStart(true);
              Iterator<UIComponent> components = row.columns();
              if (rowHolder.isUpdatePartial()) {
                  partialStart(facesContext,((AbstractCollapsibleSubTable) row).getRelativeClientId(facesContext) + ":b");
              }
              
              int columnNumber = 0;
              boolean isSubtable = false; // fix line
              while (components.hasNext()) {
                  UIComponent component = components.next();
                  if(component.isRendered()) {
                      if(component instanceof UIColumn ) {
                          component.getAttributes().put(COLUMN_CLASS, getColumnClass(rowHolder, columnNumber));
                          encodeColumn(facesContext, writer, (UIColumn)component , rowHolder);
                          columnNumber++;
                      } else if (component instanceof AbstractCollapsibleSubTable) {
                          if(component.isRendered()) {
                          	isSubtable = true; // fix line
                              encodeRowEnd(writer);
                          }
                          
                          if ( ((AbstractCollapsibleSubTable) component).isExpanded() ) {
      	                    component.encodeAll(facesContext);
                          }
       
                          rowHolder.setRowStart(true);
                      }
                  }    
              }
       
              if ( !isSubtable) encodeRowEnd(writer); // fix line
       
              if (rowHolder.isUpdatePartial()) {
                  partialEnd(facesContext);
              }
      	}
       
      }
      
      

      This renderer needs to be registered in faces-config.xml:

      <render-kit>
         <renderer>
             <component-family>org.richfaces.Data</component-family>
             <renderer-type>org.richfaces.CollapsibleSubTableRenderer</renderer-type>
             <renderer-class>bla.FixedCollapsibleSubTableRenderer</renderer-class>
         </renderer>
      </render-kit>
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                bleathem Brian Leathem
                Reporter:
                vace117 Val Blant
              • Votes:
                7 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 45 minutes
                  45m
                  Remaining:
                  Remaining Estimate - 45 minutes
                  45m
                  Logged:
                  Time Spent - Not Specified
                  Not Specified