Are there advanced uses for Grails command objects? Majority of the pages out there have a command object with all of its fields as Strings, Floats, Integers. Is there a way to make it use domain classes similar to how a Domain class may have have a reference to another domain class.
Asked
Active
Viewed 399 times
2 Answers
1
I don't see why not. Sure they can hold instances to other domain classes. Typically command objects are used when you only need a subset of the properties of your domain class or when there is no corresponding domain class.

aldrin
- 4,482
- 1
- 33
- 50
-
simple question here!is there any difference in data binding when using command objects? – Amanuel Nega Nov 11 '14 at 09:07
1
Yes, this is completely legal, and I use them this way in projects all the time. Their purpose is to validate input, and the main difference between a domain object and a command object is that the command object is not persisted.
Most of the sites probably do not use other Objects in order to make the example a bit simpler to understand.

Igor
- 33,276
- 14
- 79
- 112