JSF中的验证组

时间:2013-03-03 12:29:52

标签: jsf-2

我有两组inputText,每组都有自己的commandbutton

如何通过自己的commandbutton验证每个命令按钮不会影响其他组的每个组

   <h:form xmlns:p="http://primefaces.org/ui"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:bizbiz="http://java.sun.com/jsf/composite/util">  

    <h:head>
        <title>#{msg.Maintitle}</title>
    </h:head>

    <h:body dir="#{msg.orientation}">
        <!--        <h:form>
                    <p:panelGrid columns="3">

                        <bizbiz:loginPage/>
                        <bizbiz:signUp/>
                        <bizbiz:languageBar/>           
                    </p:panelGrid>
                </h:form>-->
        <h:form>
            <p:panelGrid id="SignUpMainPanel">
                <p:row>
                    <p:column>
                        <h:outputLabel value="#{signup_msg.firstname}"/>
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <p:inputText value="#{AccountInfo.firstName}"  required="true"/>
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <h:outputLabel value="#{signup_msg.lastname}" />
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <p:inputText value="#{AccountInfo.lastName}" required="true" />
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <h:outputLabel value="#{signup_msg.companyname}"/>
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <p:inputText value="#{AccountInfo.companyName}" required="true" />
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <h:outputLabel value="#{signup_msg.position}"/>
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <p:inputText value="#{AccountInfo.position}"  required="true"/>
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <h:outputLabel value="#{signup_msg.mobileemail}"/>
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <p:inputText value="#{AccountInfo.bizBizNetId}" required="true"/>
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <h:outputLabel value="#{signup_msg.password}"/>
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <p:password value="#{AccountInfo.password}" required="true"/>
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <h:outputLabel value="#{signup_msg.retype}"/>
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <p:inputText required="true"/>
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <h:outputLabel value="#{signup_msg.termandcondition}"/>
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <p:commandButton value="#{signup_msg.SignUp}" action="#{loginManagedBean.nextPage()}" ajax="false" process="@form" />
                    </p:column>
                </p:row>
            </p:panelGrid>
        </h:form>

        <h:form>
            <p:panelGrid id="mainContainer">  

                <p:row>
                    <p:column>
                        <h:outputLabel  value="#{login_msg.userName}: "  />  
                    </p:column>

                    <p:column>
                        <p:inputText  value="#{loginManagedBean.userName}"  id="username" label="username" required="true" />  
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        <h:outputLabel  value="#{login_msg.Password}: " />  
                    </p:column>

                    <p:column>
                        <p:password   value="#{loginManagedBean.password}" id="password" label="Surname" />  
                    </p:column>
                </p:row>

                <p:row>
                    <p:column>
                        #{login_msg.remmember}  <p:selectBooleanCheckbox id="rememberMe" value="#{loginManagedBean.remmember}" /> 
                    </p:column>
                    <p:column>
                        <!--                        <p:message/> -->
                    </p:column>

                </p:row>


                <p:row>
                    <p:column>
                    </p:column>

                    <p:column>
                        <p:commandButton  value="#{login_msg.Login}" action="#{loginManagedBean.nextPage()}" ajax="false" process="@form" id="persianButtom"  icon="ui-icon-check" style="margin:0"/>  
                    </p:column>

                </p:row>

            </p:panelGrid>  
        </h:form>
    </h:body>

</h:form>  

1 个答案:

答案 0 :(得分:0)

如何以不同的形式包含每个p:panelGrid。像这样:

<h:form>
  <p:panelGrid id="panel1" columns="1">
    <p:inputText value="#{AccountInfo.firstName}"  required="true"/>
    <p:inputText value="#{AccountInfo.lastName}"  required="true"/> 
    <p:commandButton value="Sign Up" action="#{signUpManagedBean.signUp()}" ajax="false" />
  </p:panelGrid>
</h:form>

<h:form>
  <p:panelGrid id="panel2" columns="1">
    <p:inputText value="#{UserInfo.userName}"  required="true"/>
    <p:inputText value="#{UserInfo.password}"  required="true"/> 
    <p:commandButton value="Login" action="#{signUpManagedBean.login()}" ajax="false" />
  </p:panelGrid>
</h:form>