Ahmet Karakaya
Ahmet Karakaya

Reputation: 10139

Primefaces why invoke setXXXX method when closing the Dialog

When closing the Dialog why setDataTransferRangeInSeconds() method is invoked? Normally I might not have been invoked when closing Dialog?

    <h:form>
        <p:dialog header="Service Alarm Options" 
                widgetVar="updatedlg"
                closable="true" 
                minWidth="500"
                 minHeight="1000"
                resizable="false"
                dynamic="false" 
                >
            <h:panelGrid id="servicedetails">
                <p:commandButton value="Save"
                    action="#{alarmBean.updateServiceOptions}" />
                <p:commandButton value="#{messages.exit}" icon="ui-icon-close"
                    style="valign:bottom;float:right;padding-right:20px"
                    oncomplete="updatedlg.hide();">
                </p:commandButton>
                <p:inputText
                    value="#{alarmBean.selectedDocument.dataTransferRangeInSeconds}"></p:inputText>
            </h:panelGrid>

        </p:dialog>
    </h:form>

UPDATED.

    <p:dialog header="Service Alarm Options" widgetVar="updatedlg"
        closable="true" minWidth="500" minHeight="1000" resizable="false"
        dynamic="false">
        <h:form>
            <h:panelGrid id="servicedetails">
                <p:commandButton value="Save"
                    action="#{alarmBean.selectedDocument.saveNewFeatures}" />
                <p:commandButton value="#{messages.exit}" icon="ui-icon-close"
                    style="valign:bottom;float:right;padding-right:20px"
                    onclick="updatedlg.hide();" type="button" />
                <p:inputText
                    value="#{alarmBean.selectedDocument.dataTransferRangeInSeconds}"></p:inputText>
            </h:panelGrid>
        </h:form>
    </p:dialog>

Upvotes: 0

Views: 1412

Answers (2)

Ahmet Karakaya
Ahmet Karakaya

Reputation: 10139

<p:dialog header="Service Alarm Options" widgetVar="updatedlg"
        closable="false" minWidth="500" minHeight="1000" resizable="false"
        dynamic="false">
        <h:form>
            <h:panelGrid id="servicedetails">
                <p:commandButton value="Save"
                    action="#{alarmBean.selectedDocument.saveNewFeatures}" />
                <p:commandButton value="#{messages.exit}" icon="ui-icon-close"
                    style="valign:bottom;float:right;padding-right:20px"
                    update="@form"
                    actionListener="#{alarmBean.selectedDocument.resetFeatures}"
                    oncomplete="updatedlg.hide();">                     
                </p:commandButton>              
                <p:inputText
                    value="#{alarmBean.selectedDocument.dataTransferRangeInSeconds}"></p:inputText>
            </h:panelGrid>
        </h:form>
    </p:dialog>

Upvotes: 0

partlov
partlov

Reputation: 14277

Normally not, but it is not correct to put dialog inside a form. Reorder your code and let your form be inside a dialog:

<p:dialog>
  <h:form>
      <!-- your form -->
  </h:form>
</p:dialog>

Also your exit button is AJAX button (which is default in Primefaces) which sends AJAX request and after that request it hides dialog. During that request value from input is sent and set in bean. Change button to this:

<p:commandButton value="#{messages.exit}" icon="ui-icon-close"
                style="valign:bottom;float:right;padding-right:20px"
                onclick="updatedlg.hide();" type="button"/>

This will create push button which just calls a javascript for closing dialog.

Upvotes: 0

Related Questions