[英]dataTable, rowSelect and disable commandButton (JSF2.0 + Primefaces)
I have a dataTable and I want the following behaviour: 我有一个dataTable,我想要以下行为:
I select a row and addRFI button is activated. 我选择一行并激活addRFI按钮。
I push the addRFI button, it executes the addRFICustomer method and a ConfirmDialog appears. 我按下addRFI按钮,它执行addRFICustomer方法,并出现ConfirmDialog。
I push the confirm button and the table doesn't have any row selected. 我按下确认按钮,该表没有选择任何行。
If it doesn't have row selected, addRFI button is not activated. 如果未选择行,则不会激活addRFI按钮。
My code (MyCSR.xhtml): 我的代码(MyCSR.xhtml):
<h:form id="assignForm">
<p:dataTable var="csr" value="#{myCsrController.csrModel}" id="csrList" editable="true"
selectionMode="single" selection="#{myCsrController.csrSelected}" rowKey="#{csr.id}">
<f:facet name="header">
My Work Page
</f:facet>
<p:ajax event="rowSelect" listener="#{myCsrController.onRowSelected}" update="addRFI,addTR" />
<p:ajax event="rowUnselect" listener="#{myCsrController.onRowUnselected}" update="addRFI,addTR" />
<p:column headerText="CSR Number">
<h:outputText value="#{csr.csrNumber}" />
</p:column>
...
<f:facet name="footer">
<p:commandButton id="addRFI" value="Add/Remove RFI Customer" oncomplete="wdlg1.show()" actionListener="#{myCsrController.addRFICustomer}" update=":assignForm:confirmDialog" disabled="#{!myCsrController.isSelected}" />
</f:facet>
</p:dataTable>
<p:confirmDialog id="confirmDialog" header="Add RFI Customer" widgetVar="wdlg1" message="Please confirm that an RFI Customer activity has been created for #{myCsrController.csrSelected.csrNumber}">
<p:commandButton id="confirmButton" value="Ok" oncomplete="wdlg1.hide()" update=":assignForm:csrList" />
</p:confirmDialog>
</h:form>
MyCsrController: MyCsrController:
public void addRFICustomer(ActionEvent event){
...
}
public void onRowSelected(SelectEvent event){
setIsSelected(true);
}
public void onRowUnselected(UnselectEvent event){
setIsSelected(false);
}
My problem is that the method addRFICustomer is not executed, I think that when I push the addRFI button first disable the button and the actionListener is not executed... I would like to execute the listener first, What am I doing wrong? 我的问题是方法addRFICustomer未执行,我认为当我先按下addRFI按钮时,禁用该按钮并且未执行actionListener ...我想先执行侦听器,我在做什么错? Thanks
谢谢
Check if you import ActionEvent with java.awt.event.ActionEvent
. 检查是否使用
java.awt.event.ActionEvent
导入ActionEvent。
I tried your code and find import ActionEvent with java.awt.event.ActionEvent
may be your problem. 我尝试了您的代码,并发现带有
java.awt.event.ActionEvent
导入ActionEvent可能是您的问题。
I used java.awt.event.ActionEvent
in the beginning and the result is same as yours. 我在一开始使用
java.awt.event.ActionEvent
,结果与您的结果相同。
Try import javax.faces.event.ActionEvent
. 尝试导入
javax.faces.event.ActionEvent
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.