hello,

just as additional information:

sev-en [1] allows to validate null values without the need of the required
attribute.
furthermore, it allows cross-validation. e.g.: @RequiredIf [2]

sev-en is ready to use, however, it's still beta. please include that in
your considerations.

regards,
gerhard

[1] http://os890.blogspot.com/search/label/sev-en
[2] http://os890.blogspot.com/2008/06/sev-en-requiredif.html



2008/6/7 Guy Bashan <[EMAIL PROTECTED]>:

> Thanks Simon,
>
> I implemented this specific validation the action method.
>
> Guy.
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Friday, June 06, 2008 11:05 AM
> To: MyFaces Discussion
> Subject: Re: [Faces][Core]
>
> Guy Bashan schrieb:
> >
> > Hi All,
> >
> >
> >
> > I have two fields that gets integer values. When user inputs data only
> > numbers are allowed. When user leaves field, I add grouping seperators
> > automatically (with JS).
> >
> > Now, the fields have one converter that converts the value with
> > thousands separator to integer value. If no data entered converter
> > returns null, if text data is entered (though I block it with JS, by
> > doing copy paste it is still possible), it return Double.NaN.
> >
> > In addition, each field has a validator (the same validator) that
> > checks that data is valid, by testing if value is: Double.NaN and
> > setting proper error message.
> >
> > The second field has an additional validator that validates that BOTH
> > fields are not empty. If both are empty it returns an error message.
> >
> >
> >
> > It seems like when both fields are empty the validators are not
> > activated. I assume this is because my converter returns null value
> > for the empty fields (in the getAsObject method). Should I return some
> > none-null value in order for validators to be activated?
> >
>
> Validators are never run on null values. The only validation that
> applies then is checking the "required" flag.
>
> So yes if you want your validator to run, your converter will need to
> return some non-null value. But doing multiple-field validation within a
> validator attached to one field is probably not the right way to do
> this; it was not what JSF validators were designed for. I would suggest
> doing this sort of validation in your action method instead.
>
> Check the myfaces wiki; I have a vague memory of a page that talks about
> cross-field validation. And also a vague memory that someone wrote a
> framework to do this.
>
> Regards,
> Simon
>
>


-- 

http://www.irian.at

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

Professional Support for Apache MyFaces

Reply via email to