-2
       <h:panelGrid id="userActivationGrid" columns="1">
            <p:selectOneRadio value="#{user.activationMode}" layout="pageDirection" immediate="true" >
                <f:selectItem itemLabel="${adminmsgs['create.avtivateMode.button.label']}" itemValue="${adminmsgs['create.avtivateMode.button.itemvalue.label']}"  />
                <f:selectItem itemLabel="${adminmsgs['create.avtivateMode1.button.label']}" itemValue="${adminmsgs['create.avtivateMode1.button.itemvalue.label']}"  />
                <f:ajax event="change" render="userActivationGrid" /> 
                <f:ajax event="click" listener="#{user.tempPassword()}"/>
            </p:selectOneRadio>
            <p:spacer width="10"/>
            <h:panelGrid id="manualActivationGrid" rendered="#{user.manualActivation}" columns="3">
                <h:outputLabel>#{adminmsgs['create.manualActivation.text.label']}</h:outputLabel>
                <p:inputText id="userName" immediate="true" required="true" value="#{user.userName}" requiredMessage="UserName Should Be Entered" validatorMessage="Username Should Be alphanumeric"/>
                <h:message id="userNameMsg" for="userName" />
                <h:outputLabel>#{adminmsgs['create.manualActivation1.text.label']}</h:outputLabel>
                <p:password id="password" immediate="true" required="true" validatorMessage="password should be minimum 5 character" requiredMessage="Password is Mandatory"/>
                <h:message id="passwordMsg" for="password" />
            </h:panelGrid>
        </h:panelGrid>

i am using two radio buttons and username and password should validate if i select the radio buttton or else it shud not be vaidated .Please help me thanks in advance

4

1 に答える 1

1

f:validateRegex次のようなタグ userNamepassword入力を追加することをお勧めします。

<p:inputText id="userName" immediate="true" required="true" value="#{user.userName}" requiredMessage="UserName Should Be Entered" validatorMessage="Username Should Be alphanumeric">        
  <f:validateRegex pattern="[_A-Za-z0-9]+" disabled="#{user.validationDisabled}" />
</p:inputText>

プロパティは、ラジオ ボタンの値を使用して、validationDisabled検証が必要かどうかを判断します。Primefaces + JSF バリデーターのその他の例については、こちらを参照してください。

于 2013-05-13T19:57:34.277 に答える