hi,I am going through the struts-example comes with the struts package.I have some question about the mainMenu.jsp and EditRegistrationAction.java: 1.In the mainMenu.jsp,the action class is trigerred by <html:link page="/editRegistration.do?action=Edit">.And we can found that in the structs-config.xml,there is a action mapping as follows: <action path="/editRegistration" type="org.apache.struts.webapp.example.EditRegistrationAction" name="registrationForm" scope="request" validate="false"> <forward name="success" path="/registration.jsp"/> </action> I understand that When the ActionServlet received the request from mainMenu.jsp,it will first create an instance of registrationForm if it's not exits yet.And then try to update the fields in it if there is a attribute with the same name from the request.In this case,I think only the action fields in the FormBean will be updated,and the form parameter in the EditRegistrationAction class won't be null,right? 2.in the EditRegistrationAction.java,before setting the value of the formbean,there is a statement: RegistrationForm regform = (RegistrationForm) form; what's the use of it?why not use the variable form directly?
Hi, When you click on the link, the Controller would create create an object of the class type "RegistrationForm". This RegistrationForm Class itself is an extension of the class "ActionForm". The Controller would populate the QueryString value into the property of the "RegistrationForm" object and passes this to the Process method of the Action class as a Parameter "form" of the type "ActionForm". Now when you want to use this form, you have to typecast the "form" object to "RegistrationForm" then use the corresponding get Method to retrive the variable.
Joined: Jul 25, 2002
Sorry, it is not "Process" Method but "Perform" method.