1

I am relatively new to Grails (using v2.3.5) and generating views for my Person domain class:

class Person {

String title
String firstName
String lastName

static constraints = {
    title inList: ["Mr", "Ms", "Dr"], blank: false
    firstName maxSize: 100, blank: false
    lastName maxSize: 100, blank: false
}                                      

}

The scaffolding generates the following textfield:

<g:textField name="lastName" maxlength="100" required="" value="${personInstance?.lastName}"/>

I seem to remember in previous grails versions, the domain constraints would be dynamic rather than hardcoded, e.g

<g:textField name="lastName" maxlength="personInstance?.constraints?.lastName?.maxSize" required="" value="${personInstance?.lastName}"/>

Is there a reason why this changed? It does not seem like a better practice to me.

Thanks a lot in advance!

1 Answer 1

0

you can follow your very own best practice by installing the grails templates http://www.grails.org/doc/2.2.x/ref/Command%20Line/install-templates.html into your app and modify them in a way you need it

1
  • Thanks. I was just wondering what the correct/general way of specifying the constraints size, how is everybody else doing it? Mar 20, 2014 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.