未从对话框 CommandButton 调用 ActionListener 方法

编程入门 行业动态 更新时间:2024-10-08 08:27:15
本文介绍了未从对话框 CommandButton 调用 ActionListener 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有这个代码:

<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 方法

本文发布于:2023-11-27 09:55:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637593.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对话框   方法   CommandButton   ActionListener

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!