grails-controller

Grails data binding - command objects with Lists

天大地大妈咪最大 提交于 2019-11-28 22:10:51
Grails 1.3.7 Trouble with data binding Command objects that have List content. Example Command: class Tracker { String name String description List<Unit> units = new ArrayList() } class Unit { String name Long unitMax Long unitMin } create GSP for Tracker has the Unit fields. One example: <g:textField name="units[0].unitMax" value=""/> TrackerController save method: def save = { Tracker trackerInstance -> trackerInstance = trackingService.saveOrUpdateTracker(trackerInstance) } But, always java.lang.IndexOutOfBoundsException Alternatively, if I update controller to: def save = { Tracker

How do you share common methods in different grails controllers?

Deadly 提交于 2019-11-28 16:52:33
Currently when I need to share a method like processParams(params) between different controllers, I use either inheritance or services. Both solution has some inconvenients : With inheritance, you cannot use multiple inheritance which means that you need to have all of your controller utility methods in one place. And also, there is a bug in grails that does not detect any code changes in Base Controller classes in development mode (you need to restart the app) With services, you don't have access to all injected properties like params, session, flush... So my question is : is there any other

Inject grails application configuration into service

笑着哭i 提交于 2019-11-27 21:30:46
问题 I'm creating a grails service that will interact with a 3rd party REST API via a Java library. The Java library requires credentials for the REST API by means of a url, username and password. I'd like to store these credentials in configuration/Config.groovy , make them available to a service and ensure that credentials are available to the service before it requires them. I appreciate that grailsApplication.config is available to controllers and that through a method of a service the

How do you share common methods in different grails controllers?

倖福魔咒の 提交于 2019-11-27 10:01:31
问题 Currently when I need to share a method like processParams(params) between different controllers, I use either inheritance or services. Both solution has some inconvenients : With inheritance, you cannot use multiple inheritance which means that you need to have all of your controller utility methods in one place. And also, there is a bug in grails that does not detect any code changes in Base Controller classes in development mode (you need to restart the app) With services, you don't have