Primefaces对话框仅工作一次

时间:2013-08-26 13:45:19

标签: jsf jsf-2 primefaces

我有一个菜单打开一个对话框(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>

对话框如下所示:

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

我第一次使用它时,它按预期工作,但第二次(或更多)时间我输入一个不同的电子邮件并单击该对话框关闭的按钮但该方法未被调用,只有当我做一个手册页刷新(F5)。

bean是@RequestScoped

我在editProfile方法的末尾将newEmail值设置为“”(空字符串)。

任何艰难的行为?

1 个答案:

答案 0 :(得分:2)

我终于得到了管理,并希望与大家分享答案。

如果您使用glassfish 4.0(随JSF 2.2提供),则必须使用primefaces 4.0(目前为SNAPSHOT),以下代码按预期工作:

            <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 &amp;&amp; !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 &amp;&amp; !args.validationFailed) PF('profiledlg').hide()" />
                    </h:form>
                </p:dialog>

        </div>