0

我在 p:accordionpanel 的选项卡中有一个表单,因此每个选项卡都有自己的表单和命令按钮。命令按钮工作正常,但不显示 p:messages。如果验证失败,则数据未存储在数据库中,我只是没有收到消息。

支持 bean 是会话范围的。

模板中没有表单,因此没有嵌套在另一个表单中的表单。我试图在命令按钮中添加 f:ajax render="messages",正如 BalusC 在他广受好评的 11 个问题中所建议的那样,询问命令按钮是否失败,但是命令按钮不再起作用。

谢谢你的帮助!

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

4

1 回答 1

0

将 update="@parent" 添加到 p:commandButton 解决了这个问题。

感谢 BalusC 关于更新属性的提示。

我正在使用 PrimeFaces 3.4.2

于 2013-01-11T16:33:58.560 回答