Hi Kris,
Thanks,
I'm nearly there but not yet complete. In my component I'm able to build
a FieldValidator but I cannot get it to use the @Validate annotation
from the containing class (actually a page).
So what I want is this (pseudo code)
SomePage {
@Component(id="someId")
@Validate("required") <----- how can I use this annotation from my
component??
private MyComponent myComponent;
}
MyComponent {
@Parameter(defaultPrefix = BindingConstants.VALIDATE)
@Property
private FieldValidator<?> fieldValidator;
@Component(id = "field", parameters =
{"validate=prop:fieldValidator"})
private TextField field;
}
When I build the FieldValidator I need to give it a AnnotationProvider
that is going to 'find' the @Validate annotation but how can I get
access to the @Validate annotation from the parent (ie the page)?
As a workaround I have created a FieldValidator builder that builds a
FieldValidator using a string so I can set the validator in my page
like:
SomePage {
@Component(id="someId", parameters =
{"validate=required,minlength=4"})
private MyComponent myComponent;
}
But that's a bit clumsy.
Any idea?
Martijn
On Thu, 2008-06-26 at 10:28 +0200, Kristian Marinkovic wrote:
> hi martijn,
>
> the validator parameter of the textfield requires a FieldValidator.
> you can obtain a FieldValidator through the FieldValidatorSource
> service.
>
> take a look at the PropertyEditor and the PropertyEditBlock class
> to see how FieldValidators are applied programmatically.
>
> g,
> kris
>
>
>
>
>
> "Martijn Brinkers (List)" <[EMAIL PROTECTED]>
> 26.06.2008 09:16
> Bitte antworten an
> "Tapestry users" <[email protected]>
>
>
> An
> Tapestry users <[email protected]>
> Kopie
>
> Thema
> How to inherit or have a dynamic validate
>
>
>
>
>
>
>
> I have a component containing a TextField. The TextField should support
> validation. For example:
>
> @Component(id = "field", parameters = {"validate=required,minlength=3"})
> private TextField field;
>
> But, I would like to make it possible to override the validation. So for
> example:
>
>
> @Component(id = "field", parameters =
> {"validate=prop:getTheValidationValue"})
>
> or from the tml file
>
> <input type="text" t:id = "field" t:type="TextField" value="value"
> disabled="checked" t:validate="inherit:validate"/>
>
> But I have not yet succeeded.
>
> Any tips?
>
> Martijn
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]