Fixed it! 

It was because I defined the textfield as emailText, but the property as email. 
so my message catalogue now looks like

emailText-regexp=(\\w+)@(\\w+\\.)(\\w+)(\\.\\w+)*
emailText-regexp-message=that appears to be an invalid email format, please 
check it

On a minor point I think this is a little confusing - validators are applied to 
the underlying properties but look for messages associated with the component. 
I'd actually prefer it if I could associate validators with the actual 
component e.g.

@Component(id="emailText", parameters={"value=email"})
@Validate(...)
private TextField emailText;

Toby

----- Original Message ----
From: Toby Hobson <[EMAIL PROTECTED]>
To: users@tapestry.apache.org
Sent: Tuesday, 13 May, 2008 8:37:57 PM
Subject: Regexp within a custom component

Hello again :)

I've just added some validation to my custom component and I'm having trouble 
with the regexp validator. As per the "forms" tutorial on the T5 site I've 
placed a @Validate annotation on my getEmail() accessor:

    @Validate("required,regexp")
    public String getEmail() {
        return email;
    }

I've created a message catalogue in the same package as the component and added 
some validation stuff:

email-regexp=(\\w+)@(\\w+\\.)(\\w+)(\\.\\w+)*
email-regexp-message=that appears to be an invalid email format, please check it

But Tapestry is complaining that the regexp validator requires a validation 
constraint - it's as if it dosen't understand the entry in the catalogue. The 
component can see the catalogue becuase i'm also using the message: prefix 
elsewhere in this component, it's just the regexp stuff it's struggling with.

Any ideas?

Thanks

Toby




Reply via email to