我有这个代码:
<ui:composition xmlns="www.w3/1999/xhtml" xmlns:h="java.sun/jsf/html" xmlns:f="java.sun/jsf/core" xmlns:ui="java.sun/jsf/facelets" xmlns:p="primefaces/ui" > <h:form> <h1 class="page-header "> <i class="fa fa-tachometer"></i> Dashboard</h1> <p:outputPanel id="contentPanel"> <p:commandButton value="Añadir caso de prueba" actionListener="#{testCaseBean.prepareCreateTestCase}" oncomplete="PF('addTestCaseDialog').show();" process="@this" update=":dialog"/> <p:dataTable> </p:dataTable> </p:outputPanel> </h:form> <p:dialog header="Crear caso de prueba" modal="true" id="dialog" widgetVar="addTestCaseDialog" closable="false"> <h:form id="addTestCaseDialogForm"> <p:panelGrid columns="4" styleClass="ui-noborder"> <p:outputLabel for="testCaseName" value="Nombre del caso de prueba:"/> <p:inputText id="testCaseName" value="#{testCaseBean.testCase.testCaseName}" required="true"/> <p:outputLabel for="assignedTask" value="Tarea relacionada:"/> <p:inputText id="assignedTask" value="#{testCaseBean.testCase.assignedTask}" required="true"/> <p:outputLabel for="isRegressive" value="Regresivo:" /> <p:selectBooleanCheckbox id="isRegressive" value="#{testCaseBean.testCase.isRegressive}"/> </p:panelGrid> <p:commandButton value="Guardar" actionListener="#{testCaseBean.createTestCase}" oncomplete="PF('addTestCaseDialog').hide()" process="addTestCaseDialogForm"/> <p:commandButton value="Cancelar" onclick="PF('addTestCaseDialog').hide()" immediate="true" /> </h:form> </p:dialog>而且我遇到了一个问题:对话框 commandButton 中的 actionListener 方法没有被调用,我不知道为什么.如果把这个放在然后命令按钮:
And I'm having a problem: the actionListener method from the dialog commandButton is not being called and I don't know why. If put this in then commandButton:
<p:commandButton value="Guardar" actionListener="# {testCaseBean.createTestCase}" oncomplete="PF('addTestCaseDialog').hide()" process="@this"/>方法被调用,但是表单没有被处理.
The method is called, but the form is not processed.
有什么帮助吗?
谢谢!
推荐答案我还看到您将某些字段标记为必填.如果某些必填字段未填写,则验证失败且不会调用动作侦听器.
I also see you have some fields marked as required. If some required fields are not filled up, the validation fails and the action listener is not called.
但是如果没有合适的<h:messages> 标签在您的页面或模板中,验证错误不会显示在任何地方!!
But if there are no proper < h:messages> tags in your pages or templates, the validation errors are not displayed anywhere !!
确保你也有一个合适的<h:messages> 或 显示任何可能的验证错误.
Ensure you also have a proper < h:messages> or < p:messages> to show any possible validation errors.
我们花了几个小时来解决这个问题,直到我们弄清楚......
We spend several hours with this issue until we figured it out ...
更多推荐
未从对话框 CommandButton 调用 ActionListener 方法
发布评论