On Sep 20, 2005, at 3:06 PM, Dan Diephouse wrote:

Is there an easy way to make validation conditional? For instance I have a set of radio options. If the user chooses option1, I'd like the fields under option 1 to be validated. If they choose option 2, I'd like the fields under option 2 to be validated and so on.

I looked a bit at the Required validator class, but I couldn't figure out how to check if another field was set to another value.

I was trying to figure out how to do something similar a little while back. I tried a bunch of different things before I arrived at my current solution. What I do is have something like the following for a component definition in a page spec:

<binding name="validators" value="fieldRequired"/>

Then, in the page class I have something like:

@Bean
    public abstract Required getRequired();


public Validator getFieldRequired()
    {
        if (true == someCondition)
        {
            return getRequired();
        }

        return null;
    }

I haven't tried this with a list of validators, but I suppose it would work just as well.

--
Kevin

Reply via email to