Thanks Josh and Thiago!  Here is what I ended up with in case it helps anyone 
else:

    public FieldValidator getFieldValidator() {
        String validationString = "none";
        if(attributeDefinition.isRequired()) {
            validationString = "required";
        }
        Field f = null;
        //isUseTextField just tests to see if the attribute is defined to be
        // over 50 chars or not
        if(isUseTextField()) {
            f = 
(Field)componentResources.getEmbeddedComponent("attributetextfield"); 
        } else {
            f = 
(Field)componentResources.getEmbeddedComponent("attributetextarea");
        }
        //source is FieldValidatorSource
        return source.createValidator(f, validationString, null);

    }

Thanks again!

-----Original Message-----
From: "Thiago H. de Paula Figueiredo" <thiag...@gmail.com>
Sent: Tuesday, May 24, 2011 9:52pm
To: "Tapestry users" <users@tapestry.apache.org>
Subject: Re: dynamic validation for required / not required

On Tue, 24 May 2011 19:13:31 -0300, <jackkuros...@w9z.org> wrote:

>> How do you generate your fields?
>
> Each event has an ordered list of attribute definitions.  When someone  
> registers for the event, the page loops through the list of attributes.  
> If the attribute definition says it is to be a short field, it renders  
> as a textField. If it is long, it renders as a text area. Multiple  
> people can be registered at the same time, so this loop is in another  
> loop that executes once for each attendee.

In this case, you have exactly one TextArea instance and one TextField  
instance, regardless of how many times you render them inside a loop. Give  
each one a t:id and use @InjectComponent to get them. All  
Tapestry-provided form field components are Field implementations, so you  
can use them in FormValidatorSource methods.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to