aspose file tools*
The moose likes Struts and the fly likes Passing object to Execute method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Passing object to Execute method" Watch "Passing object to Execute method" New topic
Author

Passing object to Execute method

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
IN struts 1.2 ,I like to pass an object to Execute method of action class ,How it can be done?,I do not want form object in execute method.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Sorry, but the signature of the execute method is fixed in Struts 1 and cannot be changed, so you won't be able to pass any objects to it other than the standard ones.

If you'll tell us more about the specific problem you're trying to solve, maybe we can suggest some other alternatives.


Merrill
Consultant, Sima Solutions
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
Originally posted by Merrill Higginson:
Sorry, but the signature of the execute method is fixed in Struts 1 and cannot be changed, so you won't be able to pass any objects to it other than the standard ones.

If you'll tell us more about the specific problem you're trying to solve, maybe we can suggest some other alternatives.
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
HI
I Have value object to be passed throu various layer in my application.I like to convert form bean to value object and pass it to action's execute method instead of Form object. please help in this

Hint
My Value object's property's name is different from form bean parameter naming. I hope ,i can't use apache beanUtil for this.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
As I mentioned before, your idea of passing other objects to the execute method simply isn't going to work. Aside from restrictions in Struts, you also have the restriction that you're passing data to and from the HTTP layer.

The obvious solution is just to store these value objects in the HTTPSession. If you do this, you have access to the object from any Action class anywhere along the line.

In my view, the HTTPSession has gotten an undeserved bad reputation. Developers have read white papers warning against the dangers of over-using the HTTPSession, and have taken that to mean that one should never use the HTTPSession. In today's application servers, a reasonable amount of data can be stored in an HTTPSession without incurring any significant performance hit.

If you're adamantly opposed to using the HTTPSession for these objects, the next best thing would be to declare these objects as properties of your ActionForm bean. That way they get passed along with the ActionForm.
[ June 19, 2008: Message edited by: Merrill Higginson ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Passing object to Execute method