Charlie wrote:
> My questions is, why go to all the trouble of instantiating the form
yourself 
> in your Action, when the ActionServlet will do this for you if you specify

> the form-bean name in the struts-config.xml mapping for that Action

I think a major reason that people are under this impression is that
struts-example perpetuates it.  Take a look at EditSubscriptionAction.java.
It has (or had, I have not deployed a recent version,) this code:

// Populate the subscription form
if (form == null) {
   if (log.isTraceEnabled()) {
      log.trace(" Creating new SubscriptionForm bean under key "
         + mapping.getAttribute());
   }
   form = new SubscriptionForm();
   if ("request".equals(mapping.getScope())) {
      request.setAttribute(mapping.getAttribute(), form);
   } else {
      session.setAttribute(mapping.getAttribute(), form);
   }
}
SubscriptionForm subform = (SubscriptionForm) form;

I puzzled over this the same way you did, asked about it, and was assured
that execute() will *never* be called with a null ActionForm parameter, so
that whole dance is not necessary, although it doesn't hurt anything.

But unless the example gets changed, I really can't fault people for copying
the logic and believing that it *is* necessary.  Everyone's focused on
getting 1.1 out right now, but maybe after that the example app could be
revisited and refined a little.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management

Reply via email to