2 domain classes for 1 controller in grails?
Is it possible to have 2 domain objects for one controller. In that case, how would you map them.
For eg. If开发者_JAVA百科 I have LoginController, and 2 domain classes for the same viz Login.groovy and LoginSearch.groovy.
In such a case how would you map them?
I'm not quite clear on what you want but here's my best shot. Controllers do not “map” domain classes; they are just a way to separate the domain class from the view. A controller can reference anywhere from 0 to unlimited domain classes. Most of the logic for crud operations is handled under the covers. If you need to have your domain class use a specific table name, or column names check out the following. http://www.grails.org/GORM+-+Mapping+DSL If your question is how can you generate a controller and views for default crud operations that change multiple domain classes at once this is not possible. Your best bet would be to run
Grails generate-all com.company.Login.groovy
Grails generate-all com.company.LoginSearch.groovy
Then look at the generated code and use it as a template for creating your own controller and associated views that will allow you to reference both domain classes from the same controller.
精彩评论