Rename Displayed Field Name in Grails Domain Class
Asked Answered
Z

1

6

Given the following Grails Domain Classes, how do I go about renaming the displayed field name for isbn to be "ISBN" (as opposed to the default "Isbn") and authors to be "Author(s)" (as opposed to the default "Authors")?

class Book {
    String name
    String isbn
    static hasMany = [ authors: Author ]
}

class Author {
    String name
}
Zapateado answered 22/6, 2012 at 22:29 Comment(2)
You can change the label of the property in messages.property !Ewell
@doelleri: Yes, we're using the default scaffolding that comes with Grails.Zapateado
S
8

You can just use messages.properties file for that. Go to grails-app --> i18n --> messages.properties

and define message like:

'<full packagePath>.<domain name>.<propertyName>.<attribute>' = <message>

book.isbn.label = ISBN

Stakhanovism answered 25/6, 2012 at 5:44 Comment(2)
Thanks that worked! I did have to pay special attention to the case of the package path, domain class name, etc (camelCase) in case that helps anyone else.Zapateado
yeah you need to pay attention for package hierarchy and class name and other things also..Stakhanovism

© 2022 - 2024 — McMap. All rights reserved.