The Grail is Eating Properties
July 8, 2012 Leave a comment
Problem: You are developing a Grails application. You are using scaffolding to build out your views and controller actions. Yet for some mysterious reason Grails is not rendering some properties in the views.
Solution: Did you designate some properties as transient? If so, then by default Grails does not generate transient fields in views. To fix this you need to install the template plugin, and change the value of the persistentPropNames variable:
- Install the view templates:
- grails InstallTemplates
- Now open the pertinent templates (list.gsp, show.gsp) in src/templates/scaffolding
- Change the line that reads allowedNames = domainClass.persistentProperties*.name to allowedNames = domainClass.properties*.name for each template.
- Note you are changing persistentProperties.* to just plain properties.*. This opens the door for Grails to generate fields in your views that include your transient properties.
Thanks to lo_toad for pointing this one out. This solution saved me so much time.