Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
507 views
in Technique[技术] by (71.8m points)

primefaces - ActionListener method not called from dialog CommandButton

I've this code:

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

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.

Any help?

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

PrimeFaces provides a partial rendering and view processing feature based on standard JSF 2 APIs to enable choosing what to process in JSF lifecyle and what to render in the end with ajax.

There are a couple of reserved keywords which serve as helpers.

-@this : Component that triggers the PPR is updated

-@parent: Parent of the PPR trigger is updated.

-@form: Encapsulating form of the PPR trigger is updated

-@none: PPR does not change the DOM with ajax response.

-@all: Whole document is updated as in non-ajax requests.

In Partial Page Rendering, only specified components are rendered, similarly in Partial Processing only defined components are processed. Processing means executing Apply Request Values, Process Validations, Update Model and Invoke Application JSF lifecycle phases only on defined components.

Back to your problem, you should use process @form

Hope this could help you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...