【问题标题】:Get selected item when double clicking on a Richfaces extendedDataTable in JSF2双击 JSF2 中的 Richfaces extendedDataTable 时获取所选项目
【发布时间】: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


    【解决方案1】:

    我已经用 onrowclick 实现了它:

        <a4j:jsFunction name="selectRow" action="#{chAction.selectClient}">
            <a4j:param name="selectedClientId" assignTo="#{chAction.selectedClientId}" />
        </a4j:jsFunction>
    
        <rich:dataTable id="chTable"
            rows="#{referenceData.recordsPerPage}" style="width: 100%"
            value="#{chAction.clients}" var="res" sortMode="single"
            rowClasses="oddrow, evenrow"
            onrowclick="selectRow('#{res.clientId}')"
            rowKeyVar="currRow" >
    

    您可以将事件更改为双击。

    【讨论】:

      猜你喜欢
      • 2016-04-02
      • 2011-07-23
      • 2012-02-22
      • 2011-08-24
      • 1970-01-01
      • 2015-02-07
      • 1970-01-01
      • 2011-08-23
      • 1970-01-01
      相关资源
      最近更新 更多