-
1. Re: How to Create Dynamic Header for <rich:dataTable> in RF4.1
iabughosh Jan 23, 2012 9:24 AM (in response to swastikpadhy84)helle swastik, try this:
<rich:dataTable value="#{myBean.data}"
var="row">
<f:facet name="header">
<h:outputText value="#{myBean.valueFromDB}"/>
</f:facet>
<h:column>
<f:facet name="header">column1</f:facet>
<h:outputText value="#{row.value}"/>
</h:column>
.
.
.
</rich:dataTable>
regards.
-
2. Re: How to Create Dynamic Header for <rich:dataTable> in RF4.1
swastikpadhy84 Jan 24, 2012 3:07 AM (in response to iabughosh)Hi,
Thanks for your Response. For one element this is true, but can you suggest me, what if I retrive a list from database and put all the values as a header of a data table.
Thanks
Swastik
-
3. Re: How to Create Dynamic Header for <rich:dataTable> in RF4.1
iabughosh Jan 24, 2012 3:29 AM (in response to swastikpadhy84)if you have for example List<SomeBean>, then override your SomeBean.toString() method, the output should be like this :
[bean1.toString(),bean2.toString().....]
regards.
-
4. Re: How to Create Dynamic Header for <rich:dataTable> in RF4.1
swastikpadhy84 Jan 24, 2012 3:39 AM (in response to iabughosh)Hi,
for example I have a LIst having Values "Record1", "Record2", "Record3", "Record4"
I want these values as a Header for my data table. How to iterate the list and get these values as header.
Thanks,
Swastik
-
5. Re: How to Create Dynamic Header for <rich:dataTable> in RF4.1
iabughosh Jan 24, 2012 3:52 AM (in response to swastikpadhy84)you don't have to iterate,
<h:outputText value="#{myBean.yourList}"/>
JSF will iterate through yourList for ya, if you have List<String> no more code is required else if you have List<SomeBean> you only override SomeBean.toString() method.
-
6. Re: How to Create Dynamic Header for <rich:dataTable> in RF4.1
swastikpadhy84 Jan 24, 2012 4:19 AM (in response to iabughosh)I tried this. The List valuses was came as a single header. My requirement is like each value of the list as a separate column header.
-
7. Re: How to Create Dynamic Header for <rich:dataTable> in RF4.1
iabughosh Jan 24, 2012 4:34 AM (in response to swastikpadhy84)1 of 1 people found this helpfulcolumn header is a bit different than table header, use JSF2 EL expressions to get the value from your list:
<rich:dataTable value="#{yourList}"
var="row">
<h:column>
<f:facet name="header">#{yourBean.fetchHeaderFromList(0)}</f:facet>
</h:column>
<h:outputText value="#{row.otherProperty}"/>
.
.
.
</rich:dataTable>
public String fetchHeaderFromList(int index) {
return yourList.get(index);
}
regards.