You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Mike Kienenberger <mk...@gmail.com> on 2006/03/03 22:22:57 UTC

Proposal: Make tomahawk and sandbox validators (and tags) inherit from ValidatorBase (and ValidatorTagBase)

I'm looking at http://issues.apache.org/jira/browse/TOMAHAWK-169 ( add
message attribute to all validators ) and I'm thinking the best way to
approach this is to create a ValidatorBase class that all tomahawk and
sandbox components would inherit from.   This class would provide a
copy of the following UIComponentBase methods so the same attribute
handling could be done within validators that we do with components.

    public ValueBinding getValueBinding(String name)
    public void setValueBinding(String name, ValueBinding binding)
    protected FacesContext getFacesContext()

For example,

    public String getMessage() {
        if (_message != null) return _message;
        ValueBinding vb = getValueBinding("message");
        return vb != null ?
_ComponentUtils.getStringValue(getFacesContext(), vb) : null;
    }

ValidatorBase  would also implement the message attribute, although
it'll be up to the individual validator to use getMessage() to use the
value.

Eventually, I see this class (and the related ValidatorBaseTag class)
as being put into the commons api code so that other third-party
validators could build from it, but that's another discussion.

So far, this "common validator code" is already present in
EqualsValidator and CompareToValidator.

There will likely be other common validator methods that we'll add as
time goes by.

Re: Proposal: Make tomahawk and sandbox validators (and tags) inherit from ValidatorBase (and ValidatorTagBase)

Posted by Mike Kienenberger <mk...@gmail.com>.
Right, I meant the currently-uncreated commons, not shared.

I don't see a point in putting it in shared -- we're not allowed to
change the behavior of the standard validators, and the existing
validators work per spec.

I was pretty sure you just meant to add it to tomahawk, but I wanted
to make sure you weren't pushing for commons already :)

On 3/6/06, Sean Schofield <se...@gmail.com> wrote:
> Well there is no commons package yet and I definitely think we should
> hold off on that decision for a little while.  (I assume you mean the
> new commons and not the current shared.)
>
> So if you were to create it in tomahawk that would be ok.  If its
> useful for impl then it could go in shared.
>
> Sean
>
> On 3/6/06, Mike Kienenberger <mk...@gmail.com> wrote:
> > On 3/6/06, Sean Schofield <se...@gmail.com> wrote:
> > > The timing would be best to do
> > > this right now or to wait a few weeks after we create a tomahawk
> > > branch.
> >
> > The timing for creating the ValidatorBase class, or the timing for
> > putting it into a Commons package?
> >
>

Re: Proposal: Make tomahawk and sandbox validators (and tags) inherit from ValidatorBase (and ValidatorTagBase)

Posted by Sean Schofield <se...@gmail.com>.
Well there is no commons package yet and I definitely think we should
hold off on that decision for a little while.  (I assume you mean the
new commons and not the current shared.)

So if you were to create it in tomahawk that would be ok.  If its
useful for impl then it could go in shared.

Sean

On 3/6/06, Mike Kienenberger <mk...@gmail.com> wrote:
> On 3/6/06, Sean Schofield <se...@gmail.com> wrote:
> > The timing would be best to do
> > this right now or to wait a few weeks after we create a tomahawk
> > branch.
>
> The timing for creating the ValidatorBase class, or the timing for
> putting it into a Commons package?
>

Re: Proposal: Make tomahawk and sandbox validators (and tags) inherit from ValidatorBase (and ValidatorTagBase)

Posted by Mike Kienenberger <mk...@gmail.com>.
On 3/6/06, Sean Schofield <se...@gmail.com> wrote:
> The timing would be best to do
> this right now or to wait a few weeks after we create a tomahawk
> branch.

The timing for creating the ValidatorBase class, or the timing for
putting it into a Commons package?

Re: Proposal: Make tomahawk and sandbox validators (and tags) inherit from ValidatorBase (and ValidatorTagBase)

Posted by Sean Schofield <se...@gmail.com>.
This seems like a good idea to me.  The timing would be best to do
this right now or to wait a few weeks after we create a tomahawk
branch.  I think we should hold off on tomahawk branch until the core
release.

Sean

On 3/3/06, Mike Kienenberger <mk...@gmail.com> wrote:
> I'm looking at http://issues.apache.org/jira/browse/TOMAHAWK-169 ( add
> message attribute to all validators ) and I'm thinking the best way to
> approach this is to create a ValidatorBase class that all tomahawk and
> sandbox components would inherit from.   This class would provide a
> copy of the following UIComponentBase methods so the same attribute
> handling could be done within validators that we do with components.
>
>     public ValueBinding getValueBinding(String name)
>     public void setValueBinding(String name, ValueBinding binding)
>     protected FacesContext getFacesContext()
>
> For example,
>
>     public String getMessage() {
>         if (_message != null) return _message;
>         ValueBinding vb = getValueBinding("message");
>         return vb != null ?
> _ComponentUtils.getStringValue(getFacesContext(), vb) : null;
>     }
>
> ValidatorBase  would also implement the message attribute, although
> it'll be up to the individual validator to use getMessage() to use the
> value.
>
> Eventually, I see this class (and the related ValidatorBaseTag class)
> as being put into the commons api code so that other third-party
> validators could build from it, but that's another discussion.
>
> So far, this "common validator code" is already present in
> EqualsValidator and CompareToValidator.
>
> There will likely be other common validator methods that we'll add as
> time goes by.
>