2013-08-26 62 views
-1

我有一個菜單打開一個對話框(primefaces 3.5)Primefaces對話框只工作一次

   <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爲「」(空字符串)。

有什麼?

回答

2

我終於得到了它的管理,並想與大家分享答案。

如果您使用的GlassFish 4.0(附帶JSF 2.2),你必須使用primefaces 4.0(當前快照)下面的代碼按預期工作:

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

我試圖做同樣的事情,但它沒」工作。我從〜\ AppData \ Roaming \ NetBeans \ 8.2 \ config \ GF_4.1.1 \ domain1 \ lib中刪除了服務器的primefaces庫(primefaces-6.2.jar)並替換了primefaces-6.0.3.jar。希望它能爲你工作!

+0

返回2版本是一個非常糟糕的解決方案 – Kukeltje