p:commandbutton验证表单时出错

时间:2014-04-30 16:15:24

标签: ajax validation jsf primefaces process

我有一个带有两个p:commandbutton到用户请求系统的表单,两个按钮执行相同的操作,因为它有一个p:accordeonpanel用户请求从页面的开头或结尾发布信息的两个按钮。第一个按钮正确验证了我指示的两个组件,但页面底部的第二个按钮是使我清洁字段和p:selectOneMenu,就像进行“重置”一样。对这个问题有什么看法吗?这是代码:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template=" ./../../../WEB-INF/templates/main_template.xhtml"     xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
            xmlns:h="http://xmlns.jcp.org/jsf/html"
            xmlns:f="http://xmlns.jcp.org/jsf/core"
            xmlns:p="http://primefaces.org/ui">
<ui:define name="left">
    <ui:include src="#{bundle.LeftMenuSite}">
    </ui:include>  
</ui:define>
<ui:define name="content_altern">
    <h3>#{bundle.SitSrtInfoTitle}</h3>
    <h:form id="gralForm" prependId="false">
        <p:commandButton ajax="true" style="float:right;" id="insertDataSRT0" process="@this,accPanel:mainInfoRF,accPanel:panelGridMap" update="accPanel:mainInfoRF accPanel:panelGridMap" action="#{sitSrtInfoController.create}" value="#{bundle.SendData}" icon="ui-icon ui-icon-disk"/> 
        <br/><br/>
        <p:accordionPanel activeIndex="1" multiple="true" id="accPanel"> 
            <p:tab title="#{bundle.AccTabSrtList}" id="tabSRTList">
                <ui:include src="/admin/sites/sitSrtInfo/List.xhtml"/>
            </p:tab>
            <p:tab title="#{bundle.AccTabSrtInfo}" id="tabInfo">
                <p:messages globalOnly="true"  ></p:messages>

                <p:panelGrid id="panelGridMap" columns="4">
                    <h:outputLabel value="#{bundle.SitSrtInfoLabel_siteId}"  />
                    <p:inputText  id="siteId" value="#{sRTGMapController.srtgMap.srtCode}"  required="true" />
                    <h:outputLabel value="#{bundle.SitSrtInfoLabel_latitude}"   style="text-align: right" />
                    <p:inputText id="latitude" value="#{sRTGMapController.srtgMap.latitude}"  required="true" style="width:100px"  />
                    <h:outputLabel value="#{bundle.SitSrtInfoLabel_longitude}"  style="width:50px" />
                    <p:inputText id="longitude" value="#{sRTGMapController.srtgMap.longitude}"  required="true" style="width:100px"   />
                    <h:outputLabel value="#{bundle.SitSrtInfoLabel_srRadius}" />
                    <p:inputText id="srRadius" value="#{sRTGMapController.srtgMap.radius}"  required="true"  />
                    <h:outputLabel value=" "  style="width:50px" />
                    <h:outputLabel value=" "  style="width:50px" />
                    <p:commandButton process="panelGridMap" value="#{bundle.ViewPosition}" oncomplete="if (!args.validationFailed) dlg.show()" action="#{sRTGMapController.createModel}" update="dlg panelGridMap" icon="ui-icon-pin-s" />  
                </p:panelGrid>
                <p:dialog id="dlg" widgetVar="dlg" modal="false"  styleClass="div-left" >  
                    <p:gmap id="myMap" center="#{sRTGMapController.center}" fitBounds="false"   zoom="18" type="HYBRID"  
                            styleClass="viewGMap" model="#{sRTGMapController.circleModel}" />  
                </p:dialog>  
                <p:panelGrid    id="mainInfoRF">
                    <p:row>
                        <p:column>
                            <h:outputLabel value="#{bundle.SitSrtInfoLabel_dateReq}" /></p:column>
                        <p:column>
                            <p:calendar id="dateReq" value="#{sitSrtInfoController.selected.dateReq}" navigator="true"  required="true" readonlyInput="true"  >
                                <f:convertDateTime pattern="dd/MM/yyyy" />
                            </p:calendar>
                        </p:column>
                        <p:column>
                            <h:outputLabel value="#{bundle.SitSrtInfoLabel_priority}"  />
                        </p:column>
                        <p:column>
                            <p:selectOneMenu id="priority" value="#{sitSrtInfoController.selected.priority}"  required="true"  >
                                <f:selectItems value="#{staticCatsController.priority.entrySet()}" var="entry" 
                                               itemValue="#{entry.key}" itemLabel="#{entry.value}"/>
                            </p:selectOneMenu>
                        </p:column>
                    </p:row>
                    <p:row>
                        <p:column>
                            <h:outputLabel value="#{bundle.SitSrtInfoLabel_typeSite}"  />
                        </p:column>
                        <p:column>
                            <p:selectOneMenu id="typeSite" value="#{sitSrtInfoController.selected.typeSite}" required="true"  >
                                <f:selectItems value="#{staticCatsController.typeSite.entrySet()}" var="entry" 
                                               itemValue="#{entry.key}" itemLabel="#{entry.value}"/>
                            </p:selectOneMenu>
                        </p:column>
                        <p:column>
                            <h:outputLabel value="#{bundle.SitSrtInfoLabel_region}" />
                        </p:column>
                        <p:column>
                            <p:selectOneMenu id="region" value="#{sitSrtInfoController.selected.region}" required="true"  >
                                <f:selectItems value="#{staticCatsController.region.entrySet()}" var="entry" 
                                               itemValue="#{entry.key}" itemLabel="#{entry.value}"/>
                            </p:selectOneMenu>
                        </p:column>
                    </p:row>
                    <p:row>
                        <p:column>
                            <h:outputLabel value="#{bundle.SitSrtInfoLabel_cluster}" />
                        </p:column>
                        <p:column>
                            <p:inputText id="cluster" value="#{sitSrtInfoController.selected.cluster}"   required="true"  />
                        </p:column>
                        <p:column>
                            <h:outputLabel value="#{bundle.SitSrtInfoLabel_year}"/>
                        </p:column>
                        <p:column>
                            <p:inputText id="year" value="#{sitSrtInfoController.selected.year}"  required="true"  />
                        </p:column>
                    </p:row>
                    <p:row>
                        <p:column>
                            <h:outputLabel value="#{bundle.SitSrtInfoLabel_srVersion}" /></p:column>
                        <p:column> <p:inputText id="srVersion" value="#{sitSrtInfoController.selected.srVersion}"  required="true"  /></p:column>
                        <p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_datum}" /></p:column>
                        <p:column> <p:selectOneMenu id="datum" value="#{sitSrtInfoController.selected.datum}" required="true"  >
                                <f:selectItems value="#{staticCatsController.datum.entrySet()}" var="entry" 
                                               itemValue="#{entry.key}" itemLabel="#{entry.value}"/>
                            </p:selectOneMenu></p:column>
                    </p:row>
                    <p:row>
                        <p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_morphology}"/> </p:column>
                        <p:column><p:selectOneMenu  id="morphology" value="#{sitSrtInfoController.selected.morphology}" required="true"  >
                                <f:selectItems value="#{staticCatsController.morphology.entrySet()}" var="entry" 
                                               itemValue="#{entry.key}" itemLabel="#{entry.value}"/>
                            </p:selectOneMenu></p:column>
                        <p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_colDesign}" /></p:column>
                        <p:column>  <p:selectBooleanCheckbox id="colDesign" value="#{sitSrtInfoController.selected.colDesign}" required="true"  /></p:column>
                    </p:row>
                    <p:row>
                        <p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_ownerId}"  /></p:column>
                        <p:column>  <p:selectOneMenu id="ownerId" value="#{sitSrtInfoController.selected.ownerId}"  required="true"  >
                                <f:selectItems value="#{staticCatsController.owner.entrySet()}" var="entry" 
                                               itemValue="#{entry.key}" itemLabel="#{entry.value}"/>
                            </p:selectOneMenu></p:column>
                        <p:column>  <h:outputLabel value="#{bundle.SitSrtInfoLabel_oveDesign}" /></p:column>
                        <p:column>   <p:selectBooleanCheckbox id="oveDesign" value="#{sitSrtInfoController.selected.oveDesign}" required="true"  /></p:column>
                    </p:row>
                    <p:row>
                        <p:column>  <h:outputLabel value="#{bundle.SitSrtInfoLabel_existSiteIdCms}"  /></p:column>
                        <p:column> <p:selectBooleanCheckbox id="existSiteIdCms" value="#{sitSrtInfoController.selected.existSiteIdCms}" required="true" /></p:column>
                        <p:column>  <h:outputLabel value="#{bundle.SitSrtInfoLabel_existSiteName}" /></p:column>
                        <p:column>  <p:inputText id="existSiteName" value="#{sitSrtInfoController.selected.existSiteName}"  required="true"  /></p:column>
                    </p:row>
                    <p:row>
                        <p:column>   <h:outputLabel value="#{bundle.SitSrtInfoLabel_hubSite}" /></p:column>
                        <p:column>   <p:selectBooleanCheckbox id="hubSite" value="#{sitSrtInfoController.selected.hubSite}" required="true"  /></p:column>
                        <p:column>   <h:outputLabel value="#{bundle.SitSrtInfoLabel_fiberMw}"  /></p:column>
                        <p:column>   <p:selectOneMenu id="fiberMw" value="#{sitSrtInfoController.selected.fiberMw}"  required="true" >
                                <f:selectItems value="#{staticCatsController.fiberMW.entrySet()}" var="entry" 
                                               itemValue="#{entry.key}" itemLabel="#{entry.value}" />
                            </p:selectOneMenu></p:column>
                    </p:row>
                    <p:row>
                        <p:column>      <h:outputLabel value="#{bundle.SitSrtInfoLabel_mwRepeater}" /></p:column>
                        <p:column>      <p:selectBooleanCheckbox id="mwRepeater" value="#{sitSrtInfoController.selected.mwRepeater}" required="true" /></p:column>
                        <p:column>     <h:outputLabel value="#{bundle.SitSrtInfoLabel_generatedBy}"  /></p:column>
                        <p:column>     <p:inputText id="generatedBy" value="#{sitSrtInfoController.selected.generatedBy}"  required="true"  /></p:column>
                    </p:row>
                    <p:row>
                        <p:column>     <h:outputLabel value="#{bundle.SitSrtInfoLabel_receivedBy}" /></p:column>
                        <p:column>     <p:inputText id="receivedBy" value="#{sitSrtInfoController.selected.receivedBy}"   required="true"  /></p:column>
                        <p:column>      <h:outputLabel value="#{bundle.SitSrtInfoLabel_statusReg}" /></p:column>
                        <p:column>      <p:selectBooleanCheckbox id="statusReg" value="#{secCompaniesController.selected.statusReg}"  required="true" /></p:column>
                    </p:row> 
                    <p:row>
                        <p:column>    <h:outputLabel value="#{bundle.SitSrtInfoLabel_country}" /></p:column>
                        <p:column>     <p:selectOneMenu id="countryId" value="#{geoCitiesController.countrySelected}" required="true"  >
                                <f:selectItems value="#{geoCountriesController.itemsAvailableSelectOne}"/>
                                <p:ajax listener="#{geoCitiesController.statesByCountryId}" update="stateId" /> 
                            </p:selectOneMenu></p:column>
                        <p:column>    <h:outputLabel value="#{bundle.SitSrtInfoLabel_state}" /></p:column>
                        <p:column>    <p:selectOneMenu id="stateId" value="#{geoCitiesController.stateSelected}"    required="true" >
                                <f:selectItem itemLabel="#{bundle.SelectState}" itemValue=""/>
                                <f:selectItems value="#{geoCitiesController.statesAvailable}"/>
                                <p:ajax listener="#{geoCitiesController.citiesByStateId()}" update="cityId" /> 
                            </p:selectOneMenu></p:column>
                    </p:row>
                    <p:row>
                        <p:column>   <h:outputLabel value="#{bundle.SitSrtInfoLabel_city}" /></p:column>
                        <p:column>   <p:selectOneMenu id="cityId" value="#{sitSrtInfoController.selected.city}"  required="true" >
                                <f:selectItem itemLabel="#{bundle.SelectCity}" itemValue=""/>
                                <f:selectItems value="#{geoCitiesController.citiesAvailable}"/>
                            </p:selectOneMenu></p:column>
                        <p:column>    <h:outputLabel value="#{bundle.SitSrtInfoLabel_market}"/></p:column>
                        <p:column>     <p:selectOneMenu id="market" value="#{sitSrtInfoController.selected.market}"  required="true"  >
                                <f:selectItems value="#{geoMarketsController.itemsAvailableSelectOne}"/>
                            </p:selectOneMenu></p:column>
                    </p:row>
                    <p:row>
                        <p:column colspan="1">
                            <h:outputLabel value="#{bundle.SitSrtInfoLabel_comments}" />
                        </p:column>
                        <p:column colspan="3">    
                            <p:inputTextarea value="#{sitSrtInfoController.selected.comments}"  id="comments" rows="6" cols="45"  maxlength="400" autoResize="false" required="true"/> 
                        </p:column>
                    </p:row>
                </p:panelGrid>
                <br/>
            </p:tab>  
            <p:tab title="#{bundle.AccTabSrtRF}" id="tabRFSRT">
                <ui:include src="/admin/sites/sitSrtRf/Create.xhtml"/>
            </p:tab>
            <p:tab title="#{bundle.AccTabSrtTrans}" id="tabTransSRT">
                <ui:include src="/admin/sites/sitSrtTrans/Create.xhtml"/>
            </p:tab>
        </p:accordionPanel>
        <br/><br/> 
        <p:commandButton ajax="true" style="float:right;" id="insertDataSRT1" process="@this,accPanel:mainInfoRF,accPanel:panelGridMap" update="accPanel:panelGridMap accPanel:mainInfoRF" action="#{sitSrtInfoController.create}" value="#{bundle.SendData}" icon="ui-icon ui-icon-disk"/> 

    </h:form>
</ui:define>
<ui:define name="content_middle"> 
</ui:define>

1 个答案:

答案 0 :(得分:0)

如果我理解正确,你需要重置按钮,重置会做一切。 因此,如果我理解得足够好,你可以执行重置按钮来调用bean,它会重置所有脉冲变量,之后更新@form