wood burning stoves*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Passing an object to action class" Watch "Passing an object to action class" New topic
Author

Passing an object to action class

sivaraman subbiah
Greenhorn

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
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
sivaraman subbiah
Greenhorn

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

Nope.
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
Consultant @ Xebia. Sonny Gill Tweets
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing an object to action class
 
Similar Threads
Attempted a bean operation on a null object.
Struts with Javascript problem
Struts form problem
Can we send multiple textfield of same type in struts
Problem mapping to form bean