Dennis, thanks for your reply. Your hint and some experimentation made me realize that the right place to initialize the bean parameters is in the annotation. "validators=validators:...." actually does work:
@Bean(initializer = "max=2000,message=%my-resource-bundle-error-message-key") public abstract Max getMyMaxValidator(); @Component(type="TextField", bindings = { "displayName=message:my-label", "value=myfieldval", "validators=validators:$myMaxValidator", "translator=translator:number"}) public abstract IFormComponent getMyField(); Thanks, Julian ----- Original Message ---- From: Dennis Sinelnikov <[EMAIL PROTECTED]> To: users@tapestry.apache.org Sent: Friday, November 10, 2006 3:18:32 PM Subject: Re: Tap 4 Validator questions I think your problem is in using validators: prefix in "validators=validators:...." That tells tapestry, that your listing validators. However, $myMaxValidator is actually a bean (your custom validator). Thus, you need to use bean: prefix. "validators=bean:.." If you want to use more than 1 validator on 1 component, you could do something along these lines. This is what I did in my .page, should give you an idea on what to do. <bean name="required" class="org.apache.tapestry.form.validator.Required"/> <bean name="pattern" class="org.apache.tapestry.form.validator.Pattern"> <set name="pattern" value="literal:[a-zA-Z]+"/> </bean> <component id="componentX" type="TextField"> ... <binding name="validators" value="{ beans.required, beans.pattern }"/> </component> The answer to your second question, I'm not 100% sure why it was done. It appears that org.apache.tapestry.valid.* was written pre tapestry 4.0 and org.apache.tapestry.form.validator.* was written by Howard starting tapestry 4.0+. I believe this was done for Hivemind reasons and tighter integration with components (i.e. TextField). These packages use different delegates, and that is why you're running into issues. Perhaps one of the tapestry developers can shed more light on why this was done. hth, Dennis Julian Sinai wrote: > Hi > > I'm a bit confused about validators in Tapestry 4.0.2. The doc says the > following ought to work: > > import org.apache.tapestry.annotations.*; > import org.apache.tapestry.form.validator.Max; > import org.apache.tapestry.form.validator.Validator; > > @ComponentClass(allowInformalParameters = false, allowBody = true) > public abstract class EditEventForm extends BaseComponent > { > @Bean(Max.class) > public abstract Validator getMyMaxValidator(); > > public abstract int getMyfieldval(); > > @Component(type="TextField", bindings = > { "displayName=message:my-label", "value=myfieldval", > > "validators=validators:$myMaxValidator,max=2000[%my-resource-bundle-error-message-key]", > "translator=translator:number"}) > public abstract IFormComponent getMyField(); > ... > } > > The fields display fine and work fine, however, validation doesn't work right > because the max value and message don't get filled in. Why? > > Also, what's the difference between: > > org.apache.tapestry.valid.*Validator > org.apache.tapestry.form.validator.* > > It seems only org.apache.tapestry.form.validator.* will work. For example, > if I try to use IntValidator, I get an exception that it can't be > instantiated. > > Any help is appreciated. > Thanks, > Julian > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]