Eric Wu wrote:
> I am new to this list and new to J2EE (and Struts) in general. After
> looking at some of the sources for Struts, I have one big question (its a
> big question to me anyways): Why does Struts go through all this trouble to
> initialize and introspect FormAction beans when mechanisms exist within JSP
> to do the same thing? Is this another level of decoupling to create a
> framework that is not dependent on JSP?
>
The key issue isn't so much whether you use JSP or not. The important thing
that Struts encourages you to do is separate the business logic (the stuff you
do in actions) from the presentation logic (the stuff that the user sees).
JSP's ability to introspect (using <jsp:setProperty name="xxx" property="*"/>)
requires that the form submits go to a JSP page to be executed. Most people
interpret that to mean "OK, let's just send it back to the page that created the
form in the first place", which leads you to mixing the two concepts, with the
inherent problems that this causes.
The reason that BeanUtils.populate() was created, then, was to give people who
wanted to use servlets for the processing part the same advantage -- you don't
have to code a bunch of setXxxx() method calls. You can use this as a stand
alone Java utility class even if you don't use the rest of the Struts framework
(although the effort that Struts does to deal with ActionForm beans for you
helps deal with creating user interfaces that operate the ways users expect --
in particular if the user makes a mistake and the input form is redisplayed,
they do *not* want to type all the fields in again. The ActionForm beans work
in synergy with the Struts form tags to make this easy.
>
> Any enlightenment would be appreciated...
>
> Eric Wu
> Java Architect
> www.GlobalMedic.com
Craig McClanahan