On Fri, 12 Aug 2005 19:11:40 +0200, Mike Kienenberger <[EMAIL PROTECTED]>
wrote:
I agree, sounds good Mike! I'll try if it works with the RI.
Like other people said, this issue is resolved in JSF 1.2:
https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=81
Ok. OptionalValidator is now checked in as a module of jsf-comp.
You can probably use it as is if you want. You'd just subclass
RequiredValidator and provide your own implementation of getMessage().
Or you can improve it by having the requiredValidatorChecker take an
optional requiredValidatorId and providing your own validator :)
Patches welcome.
I'm not sure how long it takes for sourceforge CVS to get updated for
anonymous access, so I can email it to you if you want.
On 8/12/05, Martin Marinschek <[EMAIL PROTECTED]> wrote:
Now that sounds good!
keep up the great work ;)
regards,
Martin
On 8/12/05, Mike Kienenberger <[EMAIL PROTECTED]> wrote:
> Alexander Jesse and I have just finished a component that will allow
> you to use a required validator rather than the required attribute.
> Lucky you! :)
>
> Basically, it's a standard validator, and a
> <requiredValidatorChecker/> component that you add to the bottom of
> your form. The component goes through the component tree at the
> apply-request-value and decode value phases and runs the
> requiredValidator validator on all EditValueHolders that contain one
> as appropriate.
>
> It works great with MyFaces, but I don't know how it'll work with
> other JSF implementations.
> MyFaces runs it after it runs all other validators (since it's the
> last element on the form) and that's not behavior that's guaranteed.
>
> I'll probably commit something to sourceforge.net.jsf-comp in an hour
or so.
>
> And yes, future implementations of JSF should dump the required
> attribute and make it a standard validator. However, there's going
> to be issues to be issues with validators that can't handle null or
> empty values.
>
> -Mike
>
>
> On 8/12/05, Marc Fonteijn <[EMAIL PROTECTED]> wrote:
> > I'm looking for ways to assign a specific error message for required
> > fields. Setting the javax.faces.component.UIInput.REQUIRED isn't a
> > solution because I want a specific message for different fields.
> >
> > I thought of implementing an custom validator (method) and doing my
own
> > "required" check instead of using the "required=true" tag.
Unfortunately
> > this is stated in section 3.5.5 in the JSF Specification 1.1:
> >
> > "Unless otherwise specified, components with a null local value
cause the
> > validation checking by this Validator to be skipped. If a component
should
> > be required to have a non-null value, a component attribute with
the name
> > required and the value true must be added to the component in order
to
> > enforce this rule."
> >
> > My conclusion is that the only way to enable this behaviour whould
be to
> > overwrite the validate method in UIInput in an custom component.
You can
> > see what that leads to, you'd have to make a custom implementation
of
> > every component that extends UIInput.
> >
> > Real solutions to this issue:
> > - Make the default validation behaviour of UIInput optional in
order to be
> > able to write a custom validator that does the empty/null checking.
> > - Implement an additional attribute on UIInput
"requiredMessage=....".
> >
> > Did I miss an alternative solution?
> >
> > Is this a flaw in the specification?
> >
> >
> >
> > Marc.
> >
> > --
> > Using Opera's revolutionary e-mail client:
http://www.opera.com/mail/
> >
>
--
http://www.irian.at
Your JSF powerhouse -
JSF Trainings in English and German
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/