2013-01-10 36 views
0

我在p:accordionpanel的選項卡中有一個表單,所以每個選項卡都有自己的形式和commandbutton。命令按鈕工作正常,但不顯示p:消息。如果驗證失敗,數據不會存儲在數據庫中,我只是不會收到消息。在p:accordianpanel選項卡中的表單不會生成驗證消息,但命令按鈕的作用不然

支持bean是會話作用域。

模板中沒有任何表單,所以沒有表單嵌套在另一個表單中。我試圖在命令按鈕中添加f:ajax render =「messages」,正如BalusC在他十分讚賞的11個問題中所建議的,以詢問命令按鈕是否失敗,但之後commandbutton不再工作。

感謝您的幫助!

<ui:define name="content"> 
    <p:accordionPanel value="#{activityAdminController.activities}" var="a" activeIndex="#{activityAdminController.activeTab}"> 
     <p:ajax event="tabChange" listener="#{activityAdminController.onTabChange}" /> 
     <p:tab title="#{a.description}"> 
      <h:form id="activityForm"> 
       <p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" /> 
       <p:panelGrid styleClass="activityGrid"> 
        <p:row>        
         <p:column><h:outputLabel for="activity" value="Activity: " /></p:column> 
         <p:column> 
          <p:inputText id="activity" value="#{a.description}" required="true" requiredMessage="Activity name must be entered" /> 
         </p:column> 

         <p:column> 
          <h:outputLabel for="duration" value="Duration: " /> 
         </p:column> 
         <p:column> 
          <p:inputText id="duration" value="#{a.duration}" > 
           <f:validateLongRange minimum="1" /> 
          </p:inputText> 
         </p:column> 
        </p:row> 

        <p:row> 
         <p:column><h:outputLabel for="active" value="Active: " /></p:column> 
         <p:column><p:selectBooleanCheckbox id="active" value="#{a.isActive}" /></p:column> 
        </p:row>             

        <p:row> 
         <p:column><h:outputLabel value="Monday from: " /> </p:column> 
         <p:column> <p:calendar value="#{a.day2FromTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /> </p:column> 
         <p:column><h:outputLabel value="to: " /> </p:column> 
         <p:column><p:calendar value="#{a.day2ToTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /> </p:column> 
        </p:row> 

        <p:row> 
         <p:column> <h:outputLabel value="Tuesday from: " /> </p:column> 
         <p:column> <p:calendar value="#{a.day3FromTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /> </p:column> 
         <p:column><h:outputLabel value="to: " /> </p:column> 
         <p:column><p:calendar value="#{a.day3ToTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /> </p:column> 
        </p:row> 

        <p:row> 
         <p:column><h:outputLabel value="Wednesday from: " /> </p:column> 
         <p:column><p:calendar value="#{a.day4FromTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /> </p:column> 
         <p:column><h:outputLabel value="to: " /> </p:column> 
         <p:column><p:calendar value="#{a.day4ToTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /> </p:column> 
        </p:row> 

        <p:row> 
         <p:column><h:outputLabel value="Thursday from: " /> </p:column> 
         <p:column> <p:calendar value="#{a.day5FromTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /> </p:column> 
         <p:column> <h:outputLabel value="to: " /> </p:column> 
         <p:column><p:calendar value="#{a.day5ToTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /> </p:column> 
        </p:row> 

        <p:row> 
         <p:column><h:outputLabel value="Friday from: " /> </p:column> 
         <p:column> <p:calendar value="#{a.day6FromTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /> </p:column> 
         <p:column><h:outputLabel value="to: " /> </p:column> 
         <p:column><p:calendar value="#{a.day6ToTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /> </p:column> 
        </p:row> 

        <p:row> 
         <p:column><h:outputLabel value="Saturday from: " /> </p:column> 
         <p:column> <p:calendar value="#{a.day7FromTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /> </p:column> 
         <p:column><h:outputLabel value="to: " /> </p:column> 
         <p:column><p:calendar value="#{a.day7ToTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /></p:column> 
        </p:row> 

        <p:row> 
         <p:column><h:outputLabel value="Sunday from: " /> </p:column> 
         <p:column><p:calendar value="#{a.day1FromTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /> </p:column> 
         <p:column><h:outputLabel value="to: " /> </p:column> 
         <p:column><p:calendar value="#{a.day1ToTime}" pattern="HH:mm" timeOnly="true" minHour="8" maxHour="22" stepMinute="30" /> </p:column> 
        </p:row> 
       </p:panelGrid> 

       <p:commandButton value="Save" action="#{activityAdminController.submit()}" icon="ui-icon-check" process="@form" /> 
      </h:form> 
     </p:tab> 
    </p:accordionPanel> 
</ui:define> 

+0

要排除一個和另一個,放''外''和重試。它有一個'autoUpdate =「true」',所以你不需要自己引用它。也請告訴PrimeFaces版本。順便說一下,在PrimeFaces中,您應該使用'update'屬性而不是'render'屬性,但考慮到它具有'autoUpdate =「true」'',這與問題更加無關。 – BalusC

回答

0

添加更新= 「@父」 爲P:的commandButton解決了這個問題。

感謝BalusC關於更新屬性的提示。

我使用PrimeFaces 3.4.2

相關問題