rich:column colspan breakBefore

Component identification parameters

Name | Value
--- | ---
component-type | org.richfaces.Column
component-class | org.richfaces.component.html.HtmlColumn
component-family | org.richfaces.Column
renderer-type | org.richfaces.ColumnRenderer
tag-class | org.richfaces.taglib.ColumnTag

## Creating the Component with a Page Tag

To create the simplest variant of column on a page, use the following syntax:

Example:

    ...
        <rich:dataTable var="set">
            <rich:column>
                <h:outputText value="#{set.property1}"/>
            </rich:column>
            <!--Set of another columns and header/footer facets-->
        </rich:dataTable>
    ...

## Creating the Component Dynamically Using Java

Example:

    import org.richfaces.component.html.HtmlColumn;
    ...
    HtmlColumn myColumn = new HtmlColumn();
    ...

## Details of Usage

To output a simple table, the <rich:column> component is used the same way as the standard <h:column>, i.e. the following code on a page is used:

Example:

    ...
        <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5">
            <rich:column>
                <f:facet name="header">State Flag</f:facet>
                <h:graphicImage value="#{cap.stateFlag}"/>
            </rich:column>
            <rich:column>
                <f:facet name="header">State Name</f:facet>
                <h:outputText value="#{cap.state}"/>
            </rich:column>
            <rich:column >
                <f:facet name="header">State Capital</f:facet>
                <h:outputText value="#{cap.name}"/>
            </rich:column>
            <rich:column>
            <f:facet name="header">Time Zone</f:facet>
                <h:outputText value="#{cap.timeZone}"/>
            </rich:column>
        </rich:dataTable>
    ...

The result is:

Generated column component

Now, in order to group columns with text information into one row in one column with a flag, use the "colspan" attribute, which is similar to an HTML one, specifying that the first column contains 3 columns. In addition, it's necessary to specify that the next column begins from the first row with the help of the "breakBefore" attribute = true.

Example:

    ...
         <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5">
            <rich:column colspan="3">
                <h:graphicImage value="#{cap.stateFlag}"/>
            </rich:column>
            <rich:column breakBefore="true">
                <h:outputText value="#{cap.state}"/>
            </rich:column>
            <rich:column >
                <h:outputText value="#{cap.name}"/>
            </rich:column>
            <rich:column>
                <h:outputText value="#{cap.timeZone}"/>
            </rich:column>
        </rich:dataTable>
    ...

As a result the following structure is rendered:

Column modified with colspan and breakbefore attributes

The same way is used for columns grouping with the "rowspan" attribute that is similar to an HTML one responsible for rows quantity definition occupied with the current one. The only thing to add in the example is an instruction to move onto the next row for each next after the second column.

Example:

    ...
        <rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5">
            <rich:column rowspan="3">
                <f:facet name="header">State Flag</f:facet>
                <h:graphicImage value="#{cap.stateFlag}"/>
            </rich:column>
            <rich:column>
                <f:facet name="header">State Info</f:facet>
                <h:outputText value="#{cap.state}"/>
            </rich:column>
            <rich:column breakBefore="true">
                <h:outputText value="#{cap.name}"/>
            </rich:column>
            <rich:column breakBefore="true">
                <h:outputText value="#{cap.timeZone}"/>
            </rich:column>
        </rich:dataTable>
    ...

As a result:

Column generated with rowspan attribute

Hence, additionally to a standard output of a particular row provided with the <h:column> component, it becomes possible to group easily the rows with special HTML attribute.

The columns also could be grouped in a particular way with the help of the <h:columnGroup> component that is described in the following chapter.

## Look-and-Feel Customization

For skinnability implementation, the components use a style class redefinition method. Default style classes are mapped on skin parameters.

There are two ways to redefine the appearance of all <rich:column> components at once:

- Redefine the corresponding skin parameters

- Add to your style sheets style classes used by a <rich:column> component

## Skin Parameters Redefinition

Skin parameters redefinition for <rich:column> are the same as for the <rich:dataTable> component.

## Definition of Custom Style Classes

Custom style classes for <rich:column> are the same as for the <rich:dataTable> component.

In order to redefine styles for all <rich:column> components on a page using CSS, it's enough to create classes with the same names and define necessary properties in them.

To change styles of particular <rich:column> components, define your own style classes in the corresponding <rich:column> attributes.

## Relevant Resources Links

Here you can see the example of <rich:column> usage and sources for the given example.