hi,

as mentioned in my previous post, i added the functionality to the
validation strategy for @RequiredIf [1]
the changes are compatible with existing versions of extval. i'll provide
details about using it with already released versions, if someone would like
to use this improvement with a released version instead of the next
milestone.

furthermore, i added some information to the wiki [2] (the section
"conditional validation via cross-validation")

regards,
gerhard

[1] http://issues.apache.org/jira/browse/EXTVAL-72
[2]
http://wiki.apache.org/myfaces/Extensions/Validator/Getting_Started/Cross_Validation

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces


2009/11/19 Gerhard Petracek <[email protected]>

> hi,
>
> since it's a nice idea to have an out-of-the-box support via @RequiredIf,
> i'm going to add such a feature to the validation strategy for @RequiredIf.
> it will be available in the next milestone (which will be published quite
> soon).
>
> regards,
> gerhard
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>
> 2009/11/18 Gerhard Petracek <[email protected]>
>
> hi,
>>
>> basically the current implementation of @RequiredIf is designed to be used
>> in combination with two text-input fields. anyway, it's quite easy to solve
>> the requirement with the cross-validation mechanism of myfaces extval. you
>> can also implement a @ValidateMyCustomConstraintIf based on the
>> infrastructure of extval. i'll create a wiki which describes the required
>> steps.
>>
>> additional information:
>> if the information is already available in a bean, you can use
>> @SkipValidation as well. (however, that's not the case in your use-case.)
>>
>> regards,
>> gerhard
>>
>> http://www.irian.at
>>
>> Your JSF powerhouse -
>> JSF Consulting, Development and
>> Courses in English and German
>>
>> Professional Support for Apache MyFaces
>>
>>
>> 2009/11/17 Mike Kienenberger <[email protected]>
>>
>> The optional validation framework is ancient at this point.  It was a
>>> short-lived, flawed project.  I don't recommend using it as is, but
>>> maybe you can use pieces of the source code as examples to accomplish
>>> some of what you need.
>>>
>>> Your best bet is to either reuse validateCompareTo
>>> (CompareToValidator) from Tomahawk or write your own validator using
>>> that Tomahawk component as a model.   You could submit it back as a
>>> requiredIf validator to MyFaces.   This is the approach I would take.
>>>
>>> Here's a generic thread on conditional required fields -- one of the
>>> few I could find on the subject -- and it also talks about using the
>>> compare-to strategy above.
>>>
>>>
>>> http://forums.sun.com/thread.jspa?trange=15&threadID=500322&forumID=427&tstart=0
>>>
>>> I see there's also a @RequiredIf annotation mentioned in the ExtVal
>>> docs.  I don't know if it's also available as a standard non-annotated
>>> validator, though.
>>>
>>> One other remote possibility is to see if a subForm can be configured
>>> to be able to do what you need.
>>>
>>> On Tue, Nov 17, 2009 at 1:51 PM, laredotornado <[email protected]>
>>> wrote:
>>> >
>>> > So you are the author of the optional validation framework?  That is
>>> > excellent.  I was reading the page but am still missing the gist of the
>>> > example.  How would you say, "If element A contains this value, then
>>> apply
>>> > this validatino rule to element B?"
>>> >
>>> > Thanks, - Dave
>>> >
>>> >
>>> > Mike Kienenberger wrote:
>>> >>
>>> >> required will have to be non-true.   I don't know if there's an el
>>> >> expression that will work in your case, so you might just have to
>>> >> leave it false.
>>> >>
>>> >> The following validator works against multiple components.
>>> >>
>>> >>     http://myfaces.apache.org/sandbox/validateCompareTo.html
>>> >>
>>> >> You can either use it as a template for creating your own validator,
>>> >> or you might be able to use the comparator attribute on it to
>>> >> accomplish what you need.  (Force it to compare against a constant
>>> >> value of true or false instead of the inputText value).  Still not
>>> >> sure how that'd interact with  <f:validateLongRange>
>>> >>
>>> >> You might also be able to use pieces of the
>>> OptionalValidationFramework.
>>> >>
>>> >>     http://wiki.apache.org/myfaces/OptionalValidationFramework
>>> >>
>>> >>
>>> >> On Tue, Nov 17, 2009 at 12:57 PM, laredotornado <
>>> [email protected]>
>>> >> wrote:
>>> >>>
>>> >>> Hi,
>>> >>>
>>> >>> I'm using MyFaces 1.2.4, Tomahawk 1.1.9.  How do I tell JSF that I
>>> only
>>> >>> want
>>> >>> to apply a validator to a text field if a checkbox on the page is
>>> >>> checked?
>>> >>> Right now I have this text field ...
>>> >>>
>>> >>> <h:inputText id="domeTourNumAdults" value="#{domeTour.numAdults}"
>>> >>>                                            required="true"
>>> >>>                                            size="60"
>>> >>>                                            maxlength="60"
>>> >>>                                            styleClass="textFields
>>> >>> numAdultsField">
>>> >>>                <f:validateLongRange minimum="0"/>
>>> >>> </h:inputText>
>>> >>>
>>> >>> but if a certain checkbox is not checked, I don't care if this field
>>> is
>>> >>> left
>>> >>> blank.  Your thoughts are appreciated, - Dave
>>> >>> --
>>> >>> View this message in context:
>>> >>>
>>> http://old.nabble.com/Only-want-to-validate-a-text-field-if-checkbox-is-checked-...-how--tp26394554p26394554.html
>>> >>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>> >>>
>>> >>>
>>> >>
>>> >>
>>> >
>>> > --
>>> > View this message in context:
>>> http://old.nabble.com/Only-want-to-validate-a-text-field-if-checkbox-is-checked-...-how--tp26394554p26395396.html
>>> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>> >
>>> >
>>>
>>
>>
>

Reply via email to