Summary
Tag Name: | <tr:column> |
Java Class: | org.apache.myfaces.trinidad.component.core.data.CoreColumn |
Component Type: | org.apache.myfaces.trinidad.CoreColumn |
Required Ancestor Tag(s): | tr:column
, tr:table
, tr:treeTable
|
The immediate children of a Table component must all be
<tr:column>
components. Each visible Trinidad Column
component creates a separate column in the Table.
Use the "header" facet on a Column to create the column header. The following example creates a two-column table with the column headers - "Firstname" and "Lastname":
<tr:table> <tr:column> <f:facet name="header"> <tr:outputText value="Firstname"/> </f:facet> ... </tr:column> <tr:column> <f:facet name="header"> <tr:outputText value="Lastname"/> </f:facet> ... </tr:column> </tr:table>
The child components of each Column display the data for each row in that column. The Column does not create child components per row; instead, each child is repeatedly rendered (stamped) once per row. Because of this stamping behavior, only certain types of components are supported as children inside a Column. Supported components include all components with no behavior and most components that implement the EditableValueHolder or ActionSource interfaces.
As each row is stamped, the data for the current row ( see
getRowData()
on the Table)
is copied into an EL reachable property.
The name of this property is defined by the var
property on the Table. Once the Table has completed rendering, this
property is removed (or reverted back to its previous value). In
the following example, the data for each row is placed under the EL
property "row". Each Column displays the data for each row by getting
further properties from the "row" property:
<tr:table var="row" value="#{myBean.employees}"> <tr:column> <tr:outputText value="#{row.firstname}"/> </tr:column> <tr:column> tr:outputText value="#{row.lastname}"/> </tr:column> </tr:table>
Formatting
The Column component supports the following attributes related to formatting:
- align
- The type of alignment to use for this column. This atribute controls left/start, right/end, or center justification of the column data.
- width
- The width of this column.
- noWrap
- Controls whether long lines of text in the column data should be wrapped.
- headerNoWrap
- Controls whether long lines of text in the column header should be wrapped.
- separateRows
- Controls whether each child of this column should be rendered in separate cells, or inside the same cell.
Sorting
In order to make this Column sortable, set the "sortable"
property to true and set "sortProperty" to the name of the
model that this column will sort. Sorting can be programatically
turned on with the setSortCritiera()
method on the\
table.
Column Groups
<tr:column>
tags can be nested to produce
groups of columns. The header of a column group spans across
all the columns it contains. The following example creates
a column group that has the header "Name" and contains
two sub columns with headers "First" and "Last":
<tr:table var="row" value="#{myBean.employees}"> <tr:column> <f:facet name="header"> <tr:outputText value="Name"/> </f:facet> <tr:column> <f:facet name="header"> <tr:outputText value="First"/> </f:facet> <tr:outputText value="#{row.firstname}"/> </tr:column> <tr:column> <f:facet name="header"> <tr:outputText value="Last"/> </f:facet> tr:outputText value="#{row.lastname}"/> </tr:column> </tr:column> </tr:table>
Supported Client Events for Client Behaviors
|
|
|
Events
Type | Phases | Description |
---|---|---|
org.apache.myfaces.trinidad.event.AttributeChangeEvent | Invoke Application, Apply Request Values |
Event delivered to describe an attribute change. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change events might include the width of a column that supported client-side resizing. |
Supported Facets
Name | Description |
---|---|
footer | the node to render as this column's footer. |
header | the node to use to render this column's header. |
Attributes
Name | Type | Supports EL? | Description |
---|---|---|---|
align | String | Yes | Valid Values:
start, end, center, left, right Default Value: start The alignment for this column. The legal values are "start", "end" and "center", for left-justified, right-justified, and center-justified respectively in LTR display. The default value is "start". |
attributeChangeListener | javax.el.MethodExpression | Only EL | a method reference to an attribute change listener. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change events might include the width of a column that supported client-side resizing. |
binding | org.apache.myfaces.trinidad.component. |
Only EL | an EL reference that will store the component instance on a bean. This can be used to give programmatic access to a component from a backing bean, or to move creation of the component to a backing bean. |
defaultSortOrder | String | Yes | Valid Values:
ascending, descending Default Value: ascending The default sort order of the column. The legal values are "ascending" or "descending" for ascending sorting or descending sorting on a first click respectively. The default value is "ascending". |
headerNoWrap | boolean | Yes | Default Value:
false whether or not the column header should be allowed to wrap |
headerText | String | Yes | text to display in the header of the column. This is a convenience that generates output equivalent to adding a "header" facet containing an outputText. |
id | String | No | the identifier for the component. The identifier
must follow a subset of the syntax allowed in HTML:
|
inlineStyle | String | Yes | the CSS styles to use for this component. |
noWrap | boolean | Yes | Default Value:
false whether or not the column contents should be allowed to wrap |
onclick | String | Yes | an onclick Javascript handler. |
ondblclick | String | Yes | an ondblclick Javascript handler. |
onkeydown | String | Yes | an onkeydown Javascript handler. |
onkeypress | String | Yes | an onkeypress Javascript handler. |
onkeyup | String | Yes | an onkeyup Javascript handler. |
onmousedown | String | Yes | an onmousedown Javascript handler. |
onmousemove | String | Yes | an onmousemove Javascript handler. |
onmouseout | String | Yes | an onmouseout Javascript handler. |
onmouseover | String | Yes | an onmouseover Javascript handler. |
onmouseup | String | Yes | an onmouseup Javascript handler. |
partialTriggers | String[] | Yes |
the IDs of the components that should trigger a partial update.
This component will listen on the trigger components. If one of the trigger components receives an event that will cause it to update in some way, this component will request to be updated too. Separate multiple triggers with a space. e.g., partialTriggers="cmp1 cmp2" Identifiers must account for NamingContainers. You can use a single colon to start the search from the root, or use multiple colons to move up through the NamingContainer. For example, "::" will pop out of this component's naming container (it pops out of itself if it is a naming container), ":::" will pop out of two naming containers, etc. The search for the partialTrigger begins from there. e.g., partialTriggers=":::commandButton1" the search begins for the component with id = commandButton1 after popping out of two naming containers relative to this component. To go into naming containers, you separate the naming containers with ':', e.g.,partialTriggers= "nc1:nc2:nc3:componentId". |
rendered | boolean | Yes | Default Value:
true whether the component is rendered. When set to false, no output will be delivered for this component (the component will not in any way be rendered, and cannot be made visible on the client). If you want to change a component's rendered attribute from false to true using PPR, set the partialTrigger attribute of its parent component so the parent refreshes and in turn will render this component. |
rowHeader | boolean | Yes | Default Value:
false Whether or not this column is a row header column. |
separateRows | boolean | Yes | Default Value:
false whether or not the children of this column should be rendered on separate rows. Setting this attribute to true will cause each child to render in its own row. Setting this to false will cause all the children to be rendered in one cell, which will rowSpan across the rows of the Columns whose children are rendered on separate rows. |
shortDesc | String | Yes | The short description of the component. This text is commonly used by user agents to display tooltip help text. |
sortProperty | String | Yes | The property that is displayed by this Column. This is the property that the framework might use to (for example) sort the Table's data. |
sortable | boolean | Yes | Default Value:
false whether or not the column is sortable. A sortable column has a clickable header that (when clicked) sorts the table by that column's property. Note that in order for a column to be sortable, this attribute must be set to "true" and the underlying model must support sorting by this column's property. This column's "sortProperty" attribute must be set if sorting is desired. |
styleClass | String | Yes | a CSS style class to use for this component. |
width | String | Yes | the preferred width of this column, e.g., "30%", "100px". |