You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Srinivas Yermal <sy...@indygosoft.com> on 2006/11/21 11:56:48 UTC

Message issue with Bean Annotation

Hi,

I have component in which I am trying to validate a zip code.

app.properties - defines these two message keys.
zip-pattern= ^\\d{5}(-?\\d{4})?$
zip-message="A ZIP Code consists of five or nine digits. Ex: 02134 or
97409-3291"

Now I have a text field for zip code. The validator for this field needs to
use this pattern and message. So I define it as follows -

@Component(type="TextField",bindings={"validators=bean:zipValidator"})
public abstract TextField getZipCodeField();

@Bean(initializer="pattern=message:zip-pattern,message= message:
zip-message")
public abstract Pattern getZipValidator();

The message keys are never getting converted by the Bean annotation. The
pattern value of the Pattern class remains as "message:zip-pattern" and
hence all values entered into the text field fail the validator.

I must be doing something silly here, but I am not able to get this working.
Thanks for any kind of help.

Regards,
Srini.

Re: Message issue with Bean Annotation

Posted by Srinivas Yermal <sy...@indygosoft.com>.
Replying to my own post -

The way to do this would be to define a TextField with validators -
@Component(type="TextField",bindings={"validators=validators:pattern=%zip-pattern[%zip-message]",
value="zip"})
public abstract TextField getZipCodeField();

Found it here -
http://tapestry.apache.org/tapestry4.1/UsersGuide/validation.html#validation.validator-binding
Srini.

On 11/21/06, Srinivas Yermal <sy...@indygosoft.com> wrote:
>
> Hi,
>
> I have component in which I am trying to validate a zip code.
>
> app.properties - defines these two message keys.
> zip-pattern= ^\\d{5}(-?\\d{4})?$
> zip-message="A ZIP Code consists of five or nine digits. Ex: 02134 or
> 97409-3291"
>
> Now I have a text field for zip code. The validator for this field needs
> to use this pattern and message. So I define it as follows -
>
> @Component(type="TextField",bindings={"validators=bean:zipValidator"})
> public abstract TextField getZipCodeField();
>
> @Bean(initializer="pattern=message:zip-pattern,message= message:
> zip-message")
> public abstract Pattern getZipValidator();
>
> The message keys are never getting converted by the Bean annotation. The
> pattern value of the Pattern class remains as "message:zip-pattern" and
> hence all values entered into the text field fail the validator.
>
> I must be doing something silly here, but I am not able to get this
> working. Thanks for any kind of help.
>
> Regards,
> Srini.
>



-- 
http://www.indygosoft.com