• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help in understanding the struts-example

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Varadaraj Krishnam
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, it is not "Process" Method but "Perform" method.
 
I carry this gun in case a vending machine doesn't give me my fritos. This gun and this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic