I have a datatable with dynamic columns and I want to be able to keep track of which one is selected. The original column tag and it's selection attribute is not usable here, since dynamic columns require the columns tag.
Here's my very simple test project's xhtml snippet:
Code: Select all
<h:form>
<p:dataTable id="table"
var="result"
value="#{tableBean.results}">
<p:columns value="#{tableBean.columnNames}" var="column" columnIndexVar="colIndex">
<f:facet name="header">
#{column}
</f:facet>
<h:panelGroup rendered="#{colIndex==0}">
<h:outputLabel>#{rowIndex}</h:outputLabel>
<h:selectBooleanCheckbox value="#{tableBean.selectedRows[result[0]]}"/>
</h:panelGroup>
</p:columns>
</p:dataTable>
<h:commandButton value="Submit"></h:commandButton>
</h:form>
Code: Select all
public Map<String, Boolean> getSelectedRows()
{
return selectedRows;
}
public void setSelectedRows(Map<String, Boolean> selectedRows)
{
this.selectedRows = selectedRows;
}
Any ideas on this? Any help would be appreciated. Also, any other row selection solutions that work with the columns tag are welcom!
Thanks in advance,
Levi