Mike,

Sorry I've got back to you late on this. If you know how to create custom
validators (I haven't delved into that aspect of JSF yet), that would be
great. I can see with your dates how the "ne" operator might be beneficial,
for the radio button/text field, maybe not. This is the way I would set up
my app with the radio button/input fields:

<t:panelGroup>
            <t:selectOneRadio id="myRadio" value="#{myBean.myRadio}" >
              <f:selectItem itemValue="0" itemLabel="#{text['radio1']}" />
              <f:selectItem itemValue="1" itemLabel="#{text['radio2']}" />
            </t:selectOneRadio>

            <h:panelGrid columns="3">

              <t:radio for="myRadio" index="0" />
                  <validateRequiredIf for="inputText1" >
              </t:radio>
              <h:inputText id="inputText1" value="#{myBean.inputText1}" />
              <t:message id="msgError" for="inputText1" />
             
              <t:radio for="myRadio" index="1" />
                  <validateRequiredIf for="inputText2" >
              </t:radio>
              <h:inputText id="inputText2" value="#{myBean.inputText2}" />
              <t:message id="msgError" for="inputText2" />

            </h:panelGrid>
</t:panelGroup>

But I'm not sure how to handle the output to <t:message>. Is that something
the "validateRequiredIf" custom code would take care of?

Let me know if there's anything I can do. (Read up on custom validation for
one.)

- Joe



Mike Kienenberger wrote:
> 
> On 8/9/06, Joe ersinghaus <[EMAIL PROTECTED]> wrote:
>> Is it possible to have more than one component validated as a group? For
>> example:  let's say I've have a radio button that when activated, text
>> must be entered/validated in that radio button's associated input field?
>>
>> In other words, only when the radio button is selected, should the input
>> filed be validated.
> 
> It's occurring to me that I need something somewhat similar.  I need
> to verify that if a starting date is specified, a second ending date
> is also specified.  Up to this point, I've been doing the validation
> like this in my action method and binding the components to my backing
> bean.
> 
> However, it'd really be more convenient to handle this as a real
> validator.
> 
> So let's brainstorm how this would work, and I'll throw together
> something from a clone of my compareToValidator.
> 
> Maybe something like validateRequiredIf for=<other component>
> operator=<an operator> value= 
> 
> So for my dates, I'd use
> 
>   <inputCalendar id="startingDate">
>       <validateRequiredIf for="endingDate" operator="ne" value="null">
>   </inputCalendar>
> 
>   <inputCalendar id="endingDate">
>       <validateRequiredIf for="startingDate" operator="ne" value="null">
>   </inputCalendar>
> 
> I have to put it on both.   If I put it only on endingDate, then if
> endingDate was null, the validateRelationship would not be executed.
> 
> 
> So how would this work for your situation?  The validator has to be on
> a non-null input component.
> 
>   <radiobutton id="radioComponent">
>       <validateRequiredIf for="associatedInput" operator="ne"
> value="null">
>   </radiobutton>
>   <inputText id="associatedInput">
>   </inputText>
> 
> Seems ackward.   Maybe it needs a better name.   Maybe we could just
> drop the operator/value attributes (it'd be true for our two use
> cases).
> 
> 

-- 
View this message in context: 
http://www.nabble.com/many-components-to-one-%28or-more%29-validation--tf2081866.html#a5808674
Sent from the MyFaces - Users forum at Nabble.com.

Reply via email to