【发布时间】:2014-01-20 01:17:16
【问题描述】:
在我的 JSF 2 应用程序中,我有一个 Richfaces 扩展数据表。当我双击一行时,我想离开这个页面,我将在另一个页面上显示所选表格条目的详细信息。我在表格页面中尝试了以下内容:
<rich:extendedDataTable
value="#{bean.loadedAnfragen}" var="anfrage"
selection="#{bean.selectedAnfrage}" id="anfragenTable"
selectionMode="single"
onrowdblclick="showAnfrage();">
... here are my columns ...
</rich:extendedDataTable>
<a4j:jsFunction name="showAnfrage" action="#{bean.showAnfrage}" />
bean 中的方法被调用,但选择(我双击的行)为空。这是相应方法的代码:
public void showAnfrage() {
UIExtendedDataTable table = ( UIExtendedDataTable )FacesContext.getCurrentInstance().getViewRoot().findComponent( "mainForm:anfragenTable" );
if( table != null ) {
for( Object selection : table.getSelection() ) {
System.out.println( "Thats the selected object: " + selection );
}
}
}
我还尝试了一些 ajax 的东西。我想在a4j:ajax 标记内使用f:setPropertyActionListener 传递选择,但这是不可能的,因为数据表本身不是操作源,因此无法调用 setPropertyActionListener 标记。
有没有人在双击扩展数据表行后获取所选项目的解决方案?
【问题讨论】:
标签: jsf-2 datatable richfaces selection