• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Moving Data from View to Model and vice versa

 
Samuel Cox
Ranch Hand
Posts: 96
Scala Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you normally do this?

We have been using two methods.

We instantiate an ActionForm from our model bean to move data from business to struts.

In each ActionForm, we have a populate method that fills in various pieces of a model bean for that particular form.

Is this fairly typical?

Thanks.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The approach you describe is pretty common. One that I use quite often is the "Value Object" or "Transfer Object" pattern. Using this pattern, you create objects that belong neither to the view, nor to the model, but are used to shuttle information to and from the two. When using struts, I sometimes find it convenient to embed the value object into the form as a property, and then use nested tags to get at the information.

Here's a link with some good information about this and other J2EE patterns.

http://java.sun.com/blueprints/corej2eepatterns/Patterns/index.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic