You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jack <st...@jakarta.apache.org> on 2002/01/06 06:22:29 UTC

Forwarding a Bean as a Request Attribute

I retrieve a Collection of items from a database and present them to a user
inside a table populated by a <logic:iterate> tag.  In the body of the
iterate tag, I have an <html:link> tag to send the user to a page with
details about that item.

How can I forward just the "selected" item as a request attribute to the
detail page when the user clicks on the link?  I saw <html:link> has
attributes to set request parameter(s) (Strings), but I want to forward the
related bean so I don't have to retrieve it again from the database.

TIA.

Jack


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Forwarding a Bean as a Request Attribute

Posted by Ted Husted <hu...@apache.org>.
When the page is rendered, any Java object that was stored in the
request vanishes. So, the bean itself many not be there to forward back.
There really isn't any good alternatives here, outside of using a form
with hidden fields, or passing additional information in the link as
part of the query string (same thing, different formats). 

For encapsulating large amounts of inforamtion between requests, I've
also seen people serialize a bean to a HTML page and pass it that way.
But I don't have any ready examples of my own. (: At least not today :)

The other not-good alternative is to store the bean(s) in the session
where they won't vanish. But that could expose memory constraints. 

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Building Java web applications with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/


Jack wrote:
> 
> I retrieve a Collection of items from a database and present them to a user
> inside a table populated by a <logic:iterate> tag.  In the body of the
> iterate tag, I have an <html:link> tag to send the user to a page with
> details about that item.
> 
> How can I forward just the "selected" item as a request attribute to the
> detail page when the user clicks on the link?  I saw <html:link> has
> attributes to set request parameter(s) (Strings), but I want to forward the
> related bean so I don't have to retrieve it again from the database.
> 
> TIA.
> 
> Jack
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>