jsf - How to display vertical and horizontal headers in p:datatable? -


i'm trying display table has both vertical , horizontal headers jsf 2.1.7 , primefaces 3.3.1.

this do:

<table>     <thead>         <tr>             <th></th>             <th>hor 1</th>             <th>hor 2</th>         </tr>     </thead>     <tbody>          <tr>             <th>vert 1</th>             <td>row 1, cell 1</td>             <td>row 1, cell 2</td>         </tr>         <tr>             <th>vert 2</th>             <td>row 2, cell 1</td>             <td>row 2, cell 2</td>         </tr>     </tbody> </table> 

this best managed achieve:

<p:datatable value="#{ctrl.values}" var="val">     <p:column styleclass="ui-state-default">         <h:outputtext value="vertical header" />     </p:column>     <p:column headertext="horizontal header">         <h:outputtext value="#{val.anything}"/>     </p:column> </p:datatable> 

the ui class styles cell header, that's enough me (no row selecting or filtering). i've still got problem: header text should replace "vertical header" in example comes resource bundle that's accessed through el. how can define values displayed each row?

can point me right direction? thanks.

there "standard" way of adding headers (and footers) data tables , columns in jsf. works standard , primefaces components. have add facet name header (or footer) p:datatable or p:column - depending if want have header (or footer) table or column.

with primefaces simpler columns. add attribute headertext (or footertext on p:column.

see following example:

<p:datatable var="person" value="#{bean.persons}">     <f:facet name="header">       persons     </f:facet>     <p:column>       <f:facet name="header">         name     </f:facet>       <h:outputtext value="#{person.name}"/>   </p:column>   <p:column headertext="email">       <h:outputtext value="#{person.email}"/>   </p:column> </p:datatable> 

but, not know if possible add "headers" rows.

please see primefaces showcase or primefaces 3.3 user guide further details.

if need different texts coming resource bundle in every row, load texts in java code , add them objects displayed in data table. create new class extends/delgates to/proxies original class intended display , add property headerlabel (value coming resource bundle). can this:

<p:datatable var="person" value="#{bean.personswithlabels}">     <p:column>       <h:outputtext value="#{person.headerlabel}"/>   </p:column>   ... </p:datatable> 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -