I have a datatable which is not selectable. So I have no selectionMode, rowKey or selection attribute set.
The datatable contains some rows and at the end of each row a button is placed to edit the row. When clicking this edit button it takes you to another page with the details of the selected row.
When this button is clicked an actionListener is invoked to set the selected object in my backing bean. The object which is given to the actionListener is the value of the var attribute of the datatable.
Code: Select all
<p:dataTable id="socialBalanceTrainingTable" widgetVar="socialBalanceTrainingTable" value="#{socialBalanceTrainingBean.socialBalanceTrainingList}"
var="socialBalanceTraining" paginator="true" rows="10" emptyMessage="#{msgs.noRecordsFound}">
<!-- Collaborator number. -->
<p:column sortBy="#{socialBalanceTraining.collaboratorInternalNumber}" filterBy="#{socialBalanceTraining.collaboratorInternalNumber}">
<f:facet name="header">
<h:outputText id="headerNumber" value="#{msgs.number}"/>
</f:facet>
<h:outputText value="#{socialBalanceTraining.collaboratorInternalNumber}"/>
</p:column>
<!-- Collaborator. -->
<p:column sortBy="#{socialBalanceTraining.fullName}" filterBy="#{socialBalanceTraining.fullName}">
<f:facet name="header">
<h:outputText value="#{msgs.collaborator}" />
</f:facet>
<h:outputText value="#{socialBalanceTraining.fullName}" />
</p:column>
<!-- Training description. -->
<p:column sortBy="#{socialBalanceTraining.trainingDescription}" filterBy="#{socialBalanceTraining.trainingDescription}">
<f:facet name="header">
<h:outputText value="#{msgs.trainingDescription}" />
</f:facet>
<h:outputText value="#{socialBalanceTraining.trainingDescription}" />
</p:column>
<!-- Training hours unpaid. -->
<p:column>
<f:facet name="header">
<h:outputText value="#{msgs.unpaid}" />
</f:facet>
<h:outputText value="#{socialBalanceTraining.trainingHoursUnpaid}" />
</p:column>
<!-- Training hours paid. -->
<p:column>
<f:facet name="header">
<h:outputText value="#{msgs.paid}" />
</f:facet>
<h:outputText value="#{socialBalanceTraining.trainingHoursPaid}" />
</p:column>
<!-- Training costs. -->
<p:column>
<f:facet name="header">
<h:outputText value="#{msgs.costs}" />
</f:facet>
<h:outputText value="#{socialBalanceTraining.trainingCost}" />
</p:column>
<!-- Training type. -->
<p:column>
<f:facet name="header">
<h:outputText value="#{msgs.type}" />
</f:facet>
<h:outputText value="#{socialBalanceTraining.trainingType.meaning}" />
</p:column>
<!-- Edit button. -->
<p:column>
<p:outputPanel>
<p:commandButton image="ui-icon ui-icon-pencil" action="edit" process="@this" update="@none"
actionListener="#{socialBalanceTrainingBean.setSelectedSocialBalanceTraining(socialBalanceTraining)}" />
</p:outputPanel>
</p:column>
</p:dataTable>
Maybe a little example will explain:
I have 5 rows in the datable when no filters are used (A, B, C, D and E).
Now I use a filter so the last two rows are shown (D and E). If I click on the edit button of D then object A is passed in the backing bean. If E is clicked then I get B. So Primefaces gives me the wrong object. I assume this is because it gets the object by index.
I assume this is a bug. Does anyone have this problem too or how can i fix it?
Note: If I set the datatable to be selectable and use the p:ajax rowSelect then the SelectEvent in the backing bean gives me the correct selected object. So in this case I have no problem but for my view the datatable should not be selectable.
Grtz,
Mynca