On Aug 16, 2005, at 6:04 PM, Kevin Menard wrote:

Hi Paul,

How would you go about making form components dynamically requirable? The Required class does not allow its required property to be changed. I'd imagine there's some easy solution to this, but I'm scratching my head trying to figure it out. Any help would be appreciated.

In case anyone is interested, I came up with a solution. The idea is to dynamically add or remove the validator, rather than try to modify its state. An example of how I did it is below:

In the spec:

    <component id="blah" type="TextField">
        <binding name="displayName" value="literal:Blah"/>
        <binding name="hidden" value="true"/>
        <binding name="validators" value="blahRequired"/>
    </component>

In the page class:

    @Bean
    public abstract Required getRequired();

    .
    .
    .

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

        return null;
    }

This seems to be working pretty well now. I like being able to move all of that logic into the page class too, rather than having it kicking around in the spec.

--
Kevin

Reply via email to