i using grails 2.4.4. in controller have used command object handling input view. works fine. want use subclasses command objects. depending on id in params
want create specific subclass command object. next want fill command object using syntax:
def finish() { final commandobject = createsubclassinstance(params.task.id) commandobject.properties = params ... }
the latter assignment fails error message "cannot set readonly property: properties class: ".
i read in documentation properties
field works domain classes. not work subclasses of command objects?
if want bind properties request command or other object, can use:
org.codehaus.groovy.grails.web.binding.databindingutils.bindobjecttoinstance(command, params)
this , other static methods of databindingutils
class real underlying methods grails uses bind commands/domains grails binding features (listeners, binding annotations @bindusing
, ...) , validate it, returning bindingresult object. if handle properties
property, loosing lot of great binding features grails.
ps: pay attention these methods can bind params
, map, request (if request hava post json).
Comments
Post a Comment