Roz*_*art 7 datatable jsf spring-webflow primefaces
我遇到了问题p:dataTable并排除了单行选择中的列.
我的dataTable中有4列.显示fileId,fileName和uploadDate需要前3个.在第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>
Run Code Online (Sandbox Code Playgroud)
并且有导航到文件详细信息页面的方法:
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");
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法从行选择中使用按钮排除列?我只需要开始处理文件,而不需要导航到其他页面.
我找到了部分解决方案。事件发生时rowSelect,我阻止执行ajax操作onClick。
我将此行添加到p:commandButton:
onclick="event.stopPropagation();"
Run Code Online (Sandbox Code Playgroud)
我说这部分起作用,因为单击带有按钮的列而不是单击按钮本身仍会执行rowSelect操作。
| 归档时间: |
|
| 查看次数: |
2839 次 |
| 最近记录: |