wood burning stoves 2.0
The moose likes Struts and the fly likes help in understanding the struts-example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "help in understanding the struts-example" Watch "help in understanding the struts-example" New topic

help in understanding the struts-example

azure ss

Joined: Jul 02, 2002
Posts: 6
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"
<forward name="success" path="/registration.jsp"/>
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?
Varadaraj Krishnam

Joined: Jul 25, 2002
Posts: 2
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.
Varadaraj Krishnam

Joined: Jul 25, 2002
Posts: 2
Sorry, it is not "Process" Method but "Perform" method.
I agree. Here's the link: http://aspose.com/file-tools
subject: help in understanding the struts-example
jQuery in Action, 3rd edition