dynamic colum selection

UI Components for JSF
Post Reply
lvarga
Posts: 3
Joined: 23 Nov 2010, 10:06

25 Jan 2011, 16:02

Hi,

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>
And here's what I have in the managed bean to select the checkboxes:

Code: Select all

public Map<String, Boolean> getSelectedRows()
  {
    return selectedRows;
  }

  public void setSelectedRows(Map<String, Boolean> selectedRows)
  {
    this.selectedRows = selectedRows;
  }
The getSelectedRows method works great, the checkboxes get selected. My problem is that the setSelectedRows method is never called, so I don't know which checkboxes the user has selected. I don't know why.

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

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 49 guests