-1

我有一个打开对话框的菜单(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 值设置为“”(空字符串)。

有什么困难吗?

4

1 回答 1

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>
于 2013-09-02T11:09:21.077 回答