jsf - Primefaces:从 p:dataTable 中的行选择中排除列

标签 jsf primefaces datatable spring-webflow

我有问题 p:dataTable并从单行选择中排除一列。

我的数据表中有 4 列。需要前 3 个来显示 fileId、fileName 和 uploadDate。在第 4 列中,每行都有一个命令按钮,用于启动文件处理操作。
但也有导航到文件详细信息页面的行选择(对事件进行 ajax 操作)。
现在,当我单击行上的任何位置(包括按钮)时,它会将我导航到详细信息页面。

这是我当前的代码:

<h:form>
    <p:dataTable id="billingFiles" value="#{billingFiles}"
        var="billingFile"
        rowKey="#{billingFile.billingFile.idBillingFile}"
        filteredValue="#{billingService.filteredBillingFileDataModels}"
        selectionMode="single" paginator="true" rows="10">

        <p:ajax event="rowSelect" listener="#{billingService.selectBillingFileRow}" />

        <p:column sortBy="#{billingFile.id}"
            filterBy="#{billingFile.id}" id="idFile"
            headerText="#{msg['billing.file.id']}"
            filterMatchMode="contains">
            <h:outputText value="#{billingFile.id}" />
        </p:column>

        <p:column sortBy="#{billingFile.uploadDate}"
            filterBy="#{billingFile.uploadDate}" id="uploadDate"
            headerText="#{msg['billing.file.upload_date']}"
            filterMatchMode="contains">
            <h:outputText value="#{billingFile.uploadDate}" />
        </p:column>

        <p:column sortBy="#{billingFile.fileName}"
            filterBy="#{billingFile.fileName}" id="fileName"
            headerText="#{msg['billing.file.file_name']}"
            filterMatchMode="contains">
            <h:outputText value="#{billingFile.fileName}" />
        </p:column>

        <p:column id="loadBillingFile">
            <p:commandButton id="loadBillingFileButton"
                rendered="#{billingFile.fileStatus.equals('UPLOADED')}"
                value="#{msg['billing.load_billing_file']}"
                action="#{billingService.loadBillingFile(billingFile.billingFile)}"
                update=":form" />
        </p:column>
    </p:dataTable>
</h:form>

还有一种导航到文件详细信息页面的方法:
public void selectBillingFileRow(SelectEvent event) {
    BillingFileDataModel billingFileDataModel = (BillingFileDataModel) event.getObject();
    if (billingFileDataModel != null) {
        selectedBillingFile = billingFileDAO.findBillingFileById(billingFileDataModel.getBillingFile().getIdBillingFile());
        FacesContext.getCurrentInstance().getExternalContext()
        .getRequestMap().put(JsfView.EVENT_KEY, "viewBillingFile");
    }
}

有没有办法从行选择中排除带有按钮的列?我只需要它来开始处理文件,而无需将我导航到其他页面。

最佳答案

我找到了我的问题的部分解决方案。
我阻止了 rowSelect执行 ajax 操作,当 onClick事件发生。

我将此行添加到 p:commandButton :

onclick="event.stopPropagation();"

我说它部分工作,因为单击带有按钮的列,而不是按钮本身,仍然执行 rowSelect行动。

关于jsf - Primefaces:从 p:dataTable 中的行选择中排除列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14879193/

相关文章:

css - jsf primefaces 对话框不会完全呈现内部布局

mysql - Union 之后的搜索查询

c# - 将DataTable异步拆分为多个Datatable

jsf - 翻转 dataTable primefaces

javascript - PrimeFaces 页面 "hangs"包含 JS "document.write"的元素更新

jquery - 刷新 Jquery 对话框内容 + JSF

javascript - 在 primefaces 对话框中滚动到

java - 如何在 Spring MVC 应用程序中使用数据表?

jquery - JSF 中的占位符与 DatePicker?

jsf - JSF 2 ConversationScope 是如何工作的?