【发布时间】:2013-09-02 03:51:31
【问题描述】:
我有一个数据表
<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
这里如果我选择任何行,我将进行 ajax 调用(与 primefaces 即时行选择示例相同)。 Ajax 在 Datatable 中。
<p:ajax event="rowSelect" listener="#{notificationBox.onRowSelect}"
oncomplete="carDialog.show();" />
我的 Backing Bean 类 -
private List<NotificationForm> notificationsList;
public NotificationForm notification;
public void onRowSelect(SelectEvent event) {
LOGGER.info("Here. +"+notification);
}
//Setter and Getters.
问题是如果我选择任何行,“通知”将变为空。我无法进一步处理。请帮忙。也欢迎任何替代方法。
编辑:-
我的托管 Bean 范围 -
<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>
【问题讨论】:
-
托管 bean 的范围是什么?
-
你的
rowKey很奇怪。 PrimeFaces 吃那个吗?它是否实现了equals/hashcode?我从来没有这样尝试过,但我更希望在这里看到#{entity.id}。 -
@LuiggiMendoza,它在视图范围内。我已经更新了详细信息。
-
@BalusC,我现在已将其编辑为 rowKey="#notificationForm.notificationId}"。但我仍然是空的。
标签: jsf jsf-2 primefaces