Meaningless Drivel is fun!
The moose likes Struts and the fly likes action objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "action objects" Watch "action objects" New topic

action objects

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

Are action objects of struts model or controller.

Jesse Beaumont
Ranch Hand

Joined: May 30, 2002
Posts: 43
I guess that depends to a certain extent on what you do in your actions. I guess they could be considered either. If you use them to simply invoke a session facade in your distributed application, I would consider them part of the controller.
Whereas if you start maniuplating your object model and accessing the RDBMS you could say that the action is part of the model.
It is probably cleaner to consider them part of the controller and implement the business logic elsewhere where reuse is more likely.

---<br />Time flies like an arrow,<br />Fruit flies like a banana
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Pradeep,
the Struts Actions form definitively the Controller part. It is technically possible to add Model logic in the Action. But as Jesse mentioned, it is advaisable to avoid to do so!
Berny Woehrlin
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
It is possible to have your Actions work as part of the model, but that is considered poor design. Struts is a model neutral framework and the Actions are supposed to be extensions of the controller.

Matthew Phillips
Ted Husted
Ranch Hand

Joined: Dec 02, 2002
Posts: 37
Personally, I consider everything in the Action package (and Config package in 1.1) to be part of the control layer, including the ActionForms.
The Action is designed to provide a bridge between the presentation layer (JSPs, templates, XMLs) and the model layer. The idea is that the view layer can talk to the Action and the Action then talks to the model layer.
Ideally, the Action should be talking to a facade that condenses what it needs to know about the model layer. For example, anything involving JDBC should be behind a facade. The Action passes the required inputs to the facade, and then relays the output to the view.
HTH, Ted.

<a href="" target="_blank" rel="nofollow">Struts in Action</a>
I agree. Here's the link:
subject: action objects
It's not a secret anymore!