You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ge...@convergys.com on 2003/06/30 15:14:51 UTC

view objects

Hey all,

Forgive a newbie his questions!

I'm trying to understand a bit of struts and I'm having one key problem.

When a with a form jsp runs, there may be dynamic data there that is not
related to user input directly.  Examples might include the 'step number'
in a wizard or perhaps some values for a drop down menu for the user to
choose from.

>From experience, it's important to have a data transfer object type of
class to provide to the jsp with the necessary data enclosed.  The key here
is that you don't want the jsp hitting any back end pieces that might
require a network or db hit while the jsp is displaying.  Otherwise, you
may get a peculiar error (network down?  database crash?) when the jsp is
half way done rendering.  Since the output of the jsp can be streamed out,
you may get a partial HTML page and then some wacky attempt at a clean
error page.  It doesn't look nice.

So I've been trying to figure out how Struts might handle this concept.
The closest I've come to an answer is the ActionForm, but.. it has
problems:

1) Are ActionForms only supplied (in the request) to the jsp after the
first request (i.e., only if the validation routines found an error).
2) How can I 'prepare' my ActionForm with data the jsp requires (such as
the page number or the values for a drop down menu)?

Thanks!

George Baxter

e-mail George.Baxter@convergys.com
www.convergys.com

--
"NOTICE:  The information contained in this electronic mail transmission is
intended by Convergys Corporation for the use of the named individual or
entity to which it is directed and may contain information that is
privileged or otherwise confidential.  If you have received this electronic
mail transmission in error, please delete it from your system without
copying or forwarding it, and notify the sender of the error by reply email
or by telephone (collect), so that the sender's address records can be
corrected."



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


Re: view objects

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Hi George,
perhaps you should take a look at the flow-of-control diagrams or UML 
graphics that can be found on the struts website.

Basically the form bean is created if you configure one, when the struts 
action servlet is given the request. It calls the reset() method and 
then the validate() method and if that's OK, calls your Action and 
passes it the form. It's in the Action that you can get all your 
resources and put them in the form (or the request attributes 
collection) so that your JSP doesn't crash. If you can't get any of your 
resources, you don't go to the JSP at all or you make sure you clean up 
first.

Adam

george.baxter@convergys.com wrote:
> Hey all,
> 
> Forgive a newbie his questions!
> 
> I'm trying to understand a bit of struts and I'm having one key problem.
> 
> When a with a form jsp runs, there may be dynamic data there that is not
> related to user input directly.  Examples might include the 'step number'
> in a wizard or perhaps some values for a drop down menu for the user to
> choose from.
> 
>>>From experience, it's important to have a data transfer object type of
> class to provide to the jsp with the necessary data enclosed.  The key here
> is that you don't want the jsp hitting any back end pieces that might
> require a network or db hit while the jsp is displaying.  Otherwise, you
> may get a peculiar error (network down?  database crash?) when the jsp is
> half way done rendering.  Since the output of the jsp can be streamed out,
> you may get a partial HTML page and then some wacky attempt at a clean
> error page.  It doesn't look nice.
> 
> So I've been trying to figure out how Struts might handle this concept.
> The closest I've come to an answer is the ActionForm, but.. it has
> problems:
> 
> 1) Are ActionForms only supplied (in the request) to the jsp after the
> first request (i.e., only if the validation routines found an error).
> 2) How can I 'prepare' my ActionForm with data the jsp requires (such as
> the page number or the values for a drop down menu)?
> 
> Thanks!
> 
> George Baxter
> 
> e-mail George.Baxter@convergys.com
> www.convergys.com
> 
> --
> "NOTICE:  The information contained in this electronic mail transmission is
> intended by Convergys Corporation for the use of the named individual or
> entity to which it is directed and may contain information that is
> privileged or otherwise confidential.  If you have received this electronic
> mail transmission in error, please delete it from your system without
> copying or forwarding it, and notify the sender of the error by reply email
> or by telephone (collect), so that the sender's address records can be
> corrected."
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 


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