未从对话框 CommandButton 调用 ActionListener 方法 [英] ActionListener method not called from dialog CommandButton

查看:43
本文介绍了未从对话框 CommandButton 调用 ActionListener 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码:

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/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 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆