【问题标题】:Primefaces dialog only working oncePrimefaces 对话框只工作一次
【发布时间】:2013-08-26 13:45:18
【问题描述】:

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

有什么困难吗?

【问题讨论】:

    标签: jsf jsf-2 primefaces


    【解决方案1】:

    我终于搞定了,想和大家分享一下答案。

    如果您使用 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-29
      • 2011-10-13
      • 1970-01-01
      相关资源
      最近更新 更多