The controller servlet (ActionServlet) is responsible for identifying the
action form and populating it with data from the request, before calling the
perform() method on your actioin class. So you are correct that the code
from EditRegistrationAction will never execute (why is it there then???).
There is one case where the code would execute however, and that is the case
where the action mapping in your struts-config.xml doen't include a
actionForm name...in this case the controller servlet doesn't create the
acton form. I would suggest that you take a look at the source for the
AtionServlet to get a sense for how this works.

-----Original Message-----
From: Bryan Field-Elliot [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 04, 2001 11:25 PM
To: [EMAIL PROTECTED]
Subject: More about that "edit form" example...


Question about the following code in EditRegistrationAction:

   // Populate the user registration form
   if (form == null) {
           if (servlet.getDebug() >= 1)
               servlet.log(" Creating new RegistrationForm bean under key "
                           + mapping.getAttribute());
       form = new RegistrationForm();
           if ("request".equals(mapping.getScope()))
               request.setAttribute(mapping.getAttribute(), form);
           else
               session.setAttribute(mapping.getAttribute(), form);
   }

Is this code ever really executed? My testing from my own app indicates 
that, even with the ActionMapping's "validate=false", and even with a 
link directly to the action without any form submission, STILL, there is 
a construction of an empty ActionForm, and it is passed to the 
process()'s "form" parameter. So the above code doesn't look like it 
ever executes. Am I off base here?

Thanks,
Bryan

Reply via email to