Quantcast

Display names for property names

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

Display names for property names

rohanranade
Hi all,

I have a domain class Person with firstName and lastName properties (and many more). Both should not allow nulls. In the GSP, I want to use the g:renderErrors tag to render validation errors. I want to have a message whenever a non-null field is not specified by the user. I notice that there is a way to set the default message in the messages.properties file -> default.null.message.

However, if I use this message, the rendering of the error in the UI tells the user the propertyname - e.g. "firstName cannot be null". I don't want the property names to be visible to the user of the app as 'firstName' , I would rather like the error messages to say - "First Name cannot be null". Is there a way to do this without repetitive custom message properties for each field?

Thanks and Regards,
Rohan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Display names for property names

Ian Roberts
On 25/07/2012 09:44, rohanranade wrote:
> However, if I use this message, the rendering of the error in the UI tells
> the user the propertyname - e.g. "firstName cannot be null". I don't want
> the property names to be visible to the user of the app as 'firstName' , I
> would rather like the error messages to say - "First Name cannot be null".
> Is there a way to do this without repetitive custom message properties for
> each field?

If you define the message code

person.firstName.label=First Name

in your messages.properties then it will use that instead of the default
for both the field label in scaffolded views and the property name in
validation messages.  You could then change your default.null.message to
something without the square brackets.

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

---------------------------------------------------------------------
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: Display names for property names

rohanranade
That did the trick. Thank you!

Rohan
Loading...