struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Husted <>
Subject Re: ActionForm Defaults/Updates Question
Date Thu, 14 Feb 2002 23:52:30 GMT
The best approach is to never let the user go directly to a JSP page.
Always pass control through an Action first, which gives you the
opportunity to pre-populate forms, and a number of any other things. 

To prime the pump, you can have the index.jsp forward to an Action.
After that it should always be [action] -> [page] -> [action]

Of course, there is nothing to prevent you from going directly to a JSP,
but in the end, it ends up being more trouble than its worth. Many
people consider it a violation of MVC.

If a form does not need a custom action (yet), you can always use the
standard ForwardAction.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web wrote:
> Hi all,
> I am new to struts and am working on converting an existing system that we
> have to Struts to get to know the framework for future development. There
> are two questions that really stick out in my mind that I am confused
> about.
> 1. What is the best way to load default values into an ActionForm bean that
> will show up the first time a user visits the site and pulls up a jsp page?
> 2. What is the best way to update a ActionForm bean to output back to the
> JSP?
>   --Say I have an action that updates fields in that bean. Do I do all this
> in the Action class or is there an easier way to do this?
> Thanks for your time and help in advance....
> Tom
> --
> To unsubscribe, e-mail:   <>
> For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message