Quantcast

Custonising validation messages

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Custonising validation messages

NiJK
I have a web application that has categories, subcategories, and companies as domain classes. When creating a new company, the user should select which subcategory it goes into. However, if they leave the subcategory drop-down empty, I get the following validation message :

Property [subcategory] of class [class Company] cannot be null

If I add

company.subcategory.null=The subcategory name is required

to the messages.properties file, I still get the default message, not my custom version.

Since Company has a belongsTo relationship with Subcategory, do I need to do something else to customise this message?

Thanks,
nick.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Custonising validation messages

Jens Lukowski
Hi nick

I think it should be

company.subcategory.nullable=The subcategory name is required

see http://grails.org/doc/1.0.x/ref/Constraints/nullable.html

regards

NiJK wrote:

> I have a web application that has categories, subcategories, and companies as
> domain classes. When creating a new company, the user should select which
> subcategory it goes into. However, if they leave the subcategory drop-down
> empty, I get the following validation message :
>
> Property [subcategory] of class [class Company] cannot be null
>
> If I add
>
> company.subcategory.null=The subcategory name is required
>
> to the messages.properties file, I still get the default message, not my
> custom version.
>
> Since Company has a belongsTo relationship with Subcategory, do I need to do
> something else to customise this message?
>
> Thanks,
> nick.
>
>


--
Jens Lukowski

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Custonising validation messages

NiJK

I was taking my cue from the error message itself rather than the constraints documentation. Now I know where to look.
Thanks, Jens.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

PropertyPlaceholder in Config.groovy???

linus1412
In reply to this post by Jens Lukowski
Hi,

I've configured the Mail Plugin via Config.groovy like so:

  grails.mail.host="mail.blueskyts.co.uk"

This is fine and it works, but I can't change the mail server after deploying the app as the config is deployed as a .class file.

How can I get the value of the mail server from somewhere else - a properties file?

What I want to do is something like this:

  grails.mail.host="${email.server}"

and have the value for ${email.server} loaded from a properties file that can be changed after the app has been deployed.

Martin


Get Hotmail on your mobile from Vodafone Try it Now!
Loading...