0

Since the following closely related question is a year and half old, I thought I should ask this anew. Keep <p:dialog> open when validation has failed

I open a form in <p:dialog>. All is fine if the form is correctly entered and submitted. If the user submits invalid info, the form stays open and the validation message appears as expected. However, the user now corrects the form and submits: The dialog closes (fine, there are no longer any errors on the form) but the commandButton's action or actionListener methods are not called. Here is my code which carefully follows the linked question.

<h:form>
    ...
    <h:commandButton value="Add Event..." onclick="addEventDlg.show()" type="button"/> 
</h:form>

<p:dialog id="dlg" header="Add Event" widgetVar="addEventDlg" modal="true">
    <h:form id="addEventForm">
        <h:messages  style="color:red;margin:8px;" />
        <table>
            <tr>
                <td style="vertical-align:center"><h:outputLabel for="eventType" value="Event Type: " /></td>
                <td>
                    <h:selectOneListbox id="eventType" value="#{addEventBean.eventType}" required='true' requiredMessage="#{msgs.eventType}">
                        <f:selectItems value="#{addEventBean.eventTypes}" var="etype" itemLabel="#{etype.name}" itemValue="#{etype}"/>
                    </h:selectOneListbox>
                </td>
            </tr>
            <tr>
                <td><h:outputLabel for="title" value="Event Title: "/></td>
                <td><h:inputText id="title" value="#{addEventBean.title}" required="true" requiredMessage="#{msgs.eventTitle}"/></td>
            </tr>
            <tr>
                <td><h:outputLabel for="occuranceDate" value="Event Date: " /></td>
                <td><p:calendar id="occuranceDate" value="#{addEventBean.dateOfOccurance}" required="true" requiredMessage="#{msgs.eventOccuranceDate}" mode="popup" 
                                        showOn="button" showButtonPanel="true" pattern="yyyy/MM/dd" navigator="true" size="10"/>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <table>
                        <tr>
                            <td><p:commandButton value="Cancel" onclick="addEventDlg.hide()" type="button"/></td>
                            <td><p:commandButton value="Submit" action="#{addEventBean.addEventAction()}" type="submit"
                                                         update="addEventForm"
                                                         oncomplete="if( !args.validationFailed) addEventDlg.hide()"/>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </h:form>
</p:dialog>

My addEventBean's action method uses controller which is injected bean.

public String addEventAction() throws PersistenceException {
    Event e = ECPEvents.getInstance(eventType);
    e.setActualDate( dateOfOccurance);
    e.setName( title);

    return controller.insertEventAction( e);
}

The previous post used the commandButton's actionListener. I want to use action. I have tried both with no change in behavior.

I am using mojarra 2.2, primefaces 3.5 and tomcat 7.

Any ideas? Thank you in advance.

Community
  • 1
  • 1
Maffitt
  • 13
  • 5

1 Answers1

0

Did you trying putting the table inside a p:panel with id (ed panelId) and trying process="panelId"

  • Based on your suggestion, I surrounded the outer table with and I added process="panelId" to the "Submit" commandButton. No change in behavior. – Maffitt Jun 23 '14 at 15:09