Tôi gặp sự cố với p:dataTable
và loại trừ một cột khỏi lựa chọn hàng đơn.Thủ tướng: Loại trừ cột khỏi lựa chọn hàng trong p: dataTable
Tôi có 4 cột trong bảng dữ liệu của mình. Đầu tiên 3 là cần thiết để hiển thị fileId, fileName và uploadDate. Trong cột thứ 4 có một nút lệnh cho mỗi hàng bắt đầu hành động xử lý tệp. Nhưng cũng có lựa chọn hàng (với hành động ajax trên sự kiện) điều hướng đến trang chi tiết tệp. Bây giờ, khi tôi bấm vào bất cứ nơi nào trên hàng (bao gồm cả nút) nó điều hướng tôi đến trang chi tiết.
Có mã hiện tại của tôi:
<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>
Và đó là phương pháp mà điều hướng để nộp chi tiết trang:
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");
}
}
Có cách nào để loại trừ cột với nút từ lựa chọn hàng? Tôi chỉ cần nó để bắt đầu xử lý tệp, mà không cần điều hướng tôi đến trang khác.
Bạn đang xử lý tệp nào, đó có phải là db không? –
Nó bắt đầu xử lý tệp txt với Spring Batch. – Rozart
Bạn có một hàngChọn Primefaces Ajax sự kiện trên dataTable thực thi trình lắng nghe sau bất cứ khi nào bạn nhấp vào một hàng: '" # {billingService.selectBillingFileRow} "' Tôi sẽ xem mã cho phương pháp này để xem liệu nó đang chuyển hướng hay chuyển tiếp trang. –