I have a datatable
<p:dataTable id="db"
value="#{notificationBox.notificationsList}"
var="notificationForm"
rows="15"
emptyMessage="${msgs.getMessage('table.empty.message')}"
paginator="true"
paginatorPosition="bottom"
rowKey="#{notificationForm}"
selection="#{notificationBox.notification}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} ( ${notificationBox.notificationsList.size()} ${msgs.getMessage('table.records')} )"
selectionMode="single"
tableStyle="height:430px">
//Rest of the code
Here If I am selecting any row, I am going for an ajax call (same as in primefaces instant row selection example). Ajax is inside the Datatable .
<p:ajax event="rowSelect" listener="#{notificationBox.onRowSelect}"
oncomplete="carDialog.show();" />
My Backing Bean class -
private List<NotificationForm> notificationsList;
public NotificationForm notification;
public void onRowSelect(SelectEvent event) {
LOGGER.info("Here. +"+notification);
}
//Setter and Getters.
The problem is if I select any row, The "notification" is coming as null. I can not process further. Please help. Any alternate approach is also welcome.
Edit:-
My Managed Bean Scope -
<managed-bean>
<managed-bean-name>notificationBox</managed-bean-name>
<managed-bean-class>com.comviva.workflow.ui.notification.NotificationBox</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
<managed-property>
<property-name>notificationDao</property-name>
<value>#{notificationDaoService}</value>
</managed-property>
<managed-property>
<property-name>userInfoDao</property-name>
<value>#{userInfoDaoProxy}</value>
</managed-property>
</managed-bean>
rowKey
is suspiciously strange. Does PrimeFaces eat that? Does it have equals/hashcode implemented? I never tried it like that, but I'd rather expect to see a#{entity.id}
here. – BalusC