This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Pass Data Between Model and Action

 
Alec Lee
Ranch Hand
Posts: 569
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sometimes when my Actions delegate tasks to some POJO classes in the Model, I need to transfer a set of closely related data e.g. a few primitives + a class+ a Collection. It seems that the "proper" OO design is to create a specific DTO class just for the purpose of returning data from Model to the Controller. This is acceptable if the model is remote like EJB. But is there any simplier way to avoid creating new classes just for the purpose of returning a set of data?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Alec Lee:
It seems that the "proper" OO design is to create a specific DTO class just for the purpose of returning data from Model to the Controller.

Yes. This is the way I would do it.

But is there any simplier way to avoid creating new classes just for the purpose of returning a set of data?

Why do you want to avoid creating an object? It does have a purpose - as you noted: to transfer data.

The alternative is using a Map, but then you lose type safety. In my mind, this is much less productive and less maintainable than creating the object. In an IDE, creating a new object and generating the getters/setters doesn't take long at all.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic