grailsconstraintsgrails-domain-classgrails-controllergrails-constraints

constraints in grails


Hi I am having some trouble getting my constraints to work in my grails project. I am trying to just make sure that the field for Site_ID is not left blank but it still accepts an blank input. Also I am trying to set the order in which the fields appear but even that is not reflecting on the page when I try it out. Here is the code:

package translation

class J2_Translations {

    String Site_ID 
    String I18NKey

    static constraints = {
        Site_ID(blank:false) 
        I18NKey()
    }
}

and here is my code for the controller, I am not doing anything special I just want the constraints to work

package translation

class J2_TranslationsController {

    def scaffold = J2_Translations
}

thanks, Ameya


Solution

  • Grails is a convention-over-configuration framework. Make sure you follow the standard Java naming conventions. Properties should be named with camel-case identifiers with the leading character in lowercase. For example:

    String siteId
    String i18nKey