[richfaces-issues] [JBoss JIRA] Created: (RF-11090) rich:collapsibleSubTable cannot be nested

Val Blant (JIRA) jira-events at lists.jboss.org
Wed Jun 29 19:21:23 EDT 2011


rich:collapsibleSubTable cannot be nested
-----------------------------------------

                 Key: RF-11090
                 URL: https://issues.jboss.org/browse/RF-11090
             Project: RichFaces
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: component-tables
    Affects Versions: 4.0.0.Final
            Reporter: Val Blant


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

{quote}
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.
{quote}

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.

{code:title=FixedCollapsibleSubTableRenderer.java|borderStyle=solid}

/**
 * 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);
        }
	}

}

{code}


This renderer needs to be registered in _faces-config.xml_:

{code}
<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>
{code}


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the richfaces-issues mailing list