wood burning stoves 2.0*
The moose likes Struts and the fly likes Moving Data from View to Model and vice versa Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Moving Data from View to Model and vice versa" Watch "Moving Data from View to Model and vice versa" New topic

Moving Data from View to Model and vice versa

Samuel Cox
Ranch Hand

Joined: Nov 16, 2004
Posts: 96

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?

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Consultant, Sima Solutions
I agree. Here's the link: http://aspose.com/file-tools
subject: Moving Data from View to Model and vice versa
Similar Threads
get the ActionForm property value into a java variable from JSP
ActionForm - View or Model ?
what is the diff b/w the actionform and dto
Exception creating bean of class
struts has action class - anything similar in jsf