You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "J. Patrick Bedell" <jp...@gmail.com> on 2006/10/05 00:35:35 UTC

making complex objects available for View to extract subobjects

Hello,
   Sorry for what is surely a FAQ from a struts newbie...
   I'm trying to make a complex object available to my JSP so that
code in the JSP can access subobjects within the original object (it's
an Amazon Item object generated with XMLBeans).  What is the right way
to make such an object available to the View jsp after the Action has
prepared it?  If I was using simple servlet processing, I would use
request.setAttribute("name", object) in the servlet and
request.getAttribute("name") to access the object within the JSP.  Is
there a similar process for Struts?
   Thanks for the help!

   Patrick
   jpbedell@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: making complex objects available for View to extract subobjects

Posted by Alex Shneyderman <a....@gmail.com>.
> J. Patrick Bedell wrote:
> > Hello,
> >   Sorry for what is surely a FAQ from a struts newbie...
> >   I'm trying to make a complex object available to my JSP so that
> > code in the JSP can access subobjects within the original object (it's
> > an Amazon Item object generated with XMLBeans).  What is the right way
> > to make such an object available to the View jsp after the Action has
> > prepared it?  If I was using simple servlet processing, I would use
> > request.setAttribute("name", object) in the servlet and
> > request.getAttribute("name") to access the object within the JSP.  Is
> > there a similar process for Struts?
>
> The process you describe will work just as well with Struts. However, if
> you want to be able not just to display the data but to support editing
> of it, you will probably want to be using the ActionForm mechanism to
> support round-trip display-edit-validate-redisplay and get the full
> benefit of the Struts 'form' tags, validation framework, etc. For
> display-only, though, the approach you describe is just fine.
>
> L.

and of course if you want all the benefits that Laurie described
without the burden of ActionForm take a look at Strtus2 :-)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: making complex objects available for View to extract subobjects

Posted by Laurie Harper <la...@holoweb.net>.
J. Patrick Bedell wrote:
> Hello,
>   Sorry for what is surely a FAQ from a struts newbie...
>   I'm trying to make a complex object available to my JSP so that
> code in the JSP can access subobjects within the original object (it's
> an Amazon Item object generated with XMLBeans).  What is the right way
> to make such an object available to the View jsp after the Action has
> prepared it?  If I was using simple servlet processing, I would use
> request.setAttribute("name", object) in the servlet and
> request.getAttribute("name") to access the object within the JSP.  Is
> there a similar process for Struts?

The process you describe will work just as well with Struts. However, if 
you want to be able not just to display the data but to support editing 
of it, you will probably want to be using the ActionForm mechanism to 
support round-trip display-edit-validate-redisplay and get the full 
benefit of the Struts 'form' tags, validation framework, etc. For 
display-only, though, the approach you describe is just fine.

L.



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org