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

Passing an object to action class

sivaraman subbiah

Joined: Dec 29, 2008
Posts: 7
Hi All,

I have a requirement like

1. I have a List<someDO> resultList; in my form bean.
2. In the jsp, I search based on certain criteria and in the action class, i set the the list in the form bean
3. Using <logic:iterate> i display the resultList in a table.
4. In each row of the table, I have an edit (link or button) .
5. On clicking the edit (link or button), I want to pass the whole object (DO) to the action class so that i can show a separate Edit jsp with all the corresponding values populated.

How to do it??

solution needed urgently. Thanks in advance
Joe Ess

Joined: Oct 29, 2001
Posts: 9188

Include some data that will identify the DO in the link to the DO edit action. This is usually the primary key of the DO in the database. In the action which populates the DO edit form, read the DO from the database.

[How To Ask Questions On JavaRanch]
sivaraman subbiah

Joined: Dec 29, 2008
Posts: 7
Thanks Joe. But is there some way to pass the bean as such through html:link , or any other way like setting the bean in request scope inside the logic:iterate itself ??
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

See The Secret Life of JavaServer Pages by Bear Bibeault

If you are using a component based framework like Wicket or Tapestry, you could write code like that, because they do a lot of 'magic' under the covers to hide the request - response nature of HTTP. But Struts or other action based frameworks don't provide this kind of functionality.

The future is here. It's just not evenly distributed yet. - William Gibson
Sonny Gill LinkedIn
I agree. Here's the link:
subject: Passing an object to action class
It's not a secret anymore!