I got a menu opening a dialog (primefaces 3.5)
<h:form>
<p:graphicImage id="img" value="../resources/img/user.jpg" style="cursor:pointer" title="My Profile" height="70px"/>
<p:overlayPanel id="imgPanel" for="img" showEffect="blind" hideEffect="fade" showEvent="mouseover" hideEvent="fade">
<h:outputLink id="editLink" value="javascript:void(0)" onclick="profiledlg.show()" title="login">Edit profile</h:outputLink><br />
<h:outputLink id="loginLink" value="javascript:void(0)" onclick="passwddlg.show()" title="login">Change password</h:outputLink><br />
<p:commandLink action="#{authBackingBean.logout}" value="Logout" />
</p:overlayPanel>
</h:form>
the dialog looks like this:
<h:form id="profiledialogform">
<p:dialog id="profiledialog" header="Edit profile" widgetVar="profiledlg" resizable="false">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="email" value="Email:" />
<p:inputText value="#{editProfileBean.newEmail}"
id="email" required="true" label="email" />
<f:facet name="footer">
<p:commandButton id="editProfileButton" value="Edit profile"
actionListener="#{editProfileBean.editProfile}" oncomplete="profiledlg.hide()" update=":profiledialogform" >
<p:resetInput target=":profiledialogform" />
</p:commandButton>
</f:facet>
</h:panelGrid>
</p:dialog>
</h:form>
The first time I use it, it works as intended, but the second (or any more) time I enter a different email and click the button the dialog closes but the method is not called, only if I do a manual page refresh (F5).
The bean is @RequestScoped
I set the newEmail value to "" (empty String) at the end of the editProfile method.
any toughts?
I finally got it managed and want to share the answer with all of you.
If you use glassfish 4.0 (ships with JSF 2.2) you have to use primefaces 4.0 (currently SNAPSHOT) the following code works as intended:
<div id="header_right" class="floatr">
<h:form>
<p:graphicImage id="img" value="../resources/img/user_1.jpg" style="cursor:pointer" title="My Profile" height="70px"/>
<p:overlayPanel id="imgPanel" for="img" showEffect="blind" hideEffect="fade" showEvent="mouseover" hideEvent="fade">
<p:commandLink value="Edit profile" update=":profiledialog" oncomplete="PF('profiledlg').show()">
<p:resetInput target=":profiledialogform" />
</p:commandLink><br />
<p:commandLink value="Change password" update=":passwddialog" oncomplete="PF('passwddlg').show()">
<p:resetInput target=":passwddialogform" />
</p:commandLink><br />
<p:commandLink action="#{authBackingBean.logout()}" value="Logout" />
</p:overlayPanel>
</h:form>
<p:dialog id="passwddialog" header="Change password" widgetVar="passwddlg" resizable="false">
<h:form id="passwddialogform">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="oldpasswd" value="Old password:" />
<h:inputSecret value="#{changePasswordBean.oldpassword}"
id="oldpasswd" required="true" label="oldpassword" />
<h:outputLabel for="password" value="New password:" />
<h:inputSecret value="#{changePasswordBean.newpassword}"
id="password" required="true" label="password" />
<f:facet name="footer">
<p:commandButton id="changePasswordButton" value="Change password"
action="#{changePasswordBean.changePassword}" update="@form"
oncomplete="if (args && !args.validationFailed) PF('passwddlg').hide()">
</p:commandButton>
</f:facet>
</h:panelGrid>
</h:form>
</p:dialog>
<p:dialog id="profiledialog" header="Edit profile" widgetVar="profiledlg" resizable="false">
<h:form id="profiledialogform">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="email" value="Email:" />
<p:inputText value="#{editProfileBean.newEmail}"
id="email" required="true" label="email" />
</h:panelGrid>
<p:commandButton value="Edit profile" action="#{editProfileBean.editProfile}"
update="@form" oncomplete="if (args && !args.validationFailed) PF('profiledlg').hide()" />
</h:form>
</p:dialog>
</div>