Term
What is an ActionServlet? |
|
Definition
The central component of a the Struts controller is the ActionServlet.
1) On start up, it reads the Struts Configuration file and loads it in to the memory of the init() method.
2)In the doGet() and doPost() methods, it intercepts the HTTP request and handles it appropriately |
|
|
Term
Where is the Struts-Configuration information stored. |
|
Definition
struts-config.xml is located in the WEB-INF directory. Additionally, the name of the struts config file can be configured in the web.xml |
|
|
Term
What is the Request Processor? |
|
Definition
It is one of the Core Controller Components in Struts. Once the ActionServlet intercepts the HTTP request,it does not do much. It delegates the request handling to another class called RequestProcessor by invoking the process() method. Most of the Struts Controller functionality is embedded in the process() method of the RequestProcessor |
|
|
Term
Where is the mapping from the URL Path to an Action Class Defined? |
|
Definition
The ActionMapping Section of the StrutsConfig File. ignore parenthesis: () () () ()
() () |
|
|
Term
What is an ActionForm aka FormBean |
|
Definition
The ActionForm is a Java bean that extends org.apache.struts.action.ActionForm
It contains the data entered from the form UI on the client side. It is automatically populated on the server side by the RequestProcessor by iterating through the HTTP request parameters using Java introspective.
(Java introspection is a special form of Reflection using the JavaBeans properties instead of directly using the reflection to set the field values. It uses the setter emthod to set the field to set the field value and getter method to retrieve the field value.) |
|
|
Term
Can you explain the signature of the execute method in the Action class? |
|
Definition
Public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)throws exception. The execute () method should preferably contain only the presentation logic and the starting point in the web tier to invoke the business logic. |
|
|
Term
What is an ActionForward? |
|
Definition
ActionForward is the class that encapsulates the next view information. Struts encourages you to not had code JSP names for the next view. This association of the logical name and the physical JSP page is encapsulated in the ActionForward instance returned from the execute method. The ActionForward can be logical or global the forward element ()in the ActionMapping contains 3 elements name, path and redirect. |
|
|
Term
What are the various ways of performing validation? |
|
Definition
1) JavaScript 2)Overriding the validate method in the ActionForm class. 3)Struts Validatior framework. |
|
|
Term
How do you integrate the validator framework with a struts application? |
|
Definition
1) Ensure that the plugin is configured in the struts-config.xml 2) Set the location of MessageResources.properties message-resource (encased in<>) of the strust-config.xml
c) in action(encased in<>) of struts-config.xml, set validate and input attributes. validate ="true" input="/login.jsp. d) Extend ValidatorForm in the form class if one is being used. e) Edit validation.xml to map the properties of the form bean to the definitions in the validator-rules.xml
f) Place the error messages in the Message.Resources.properties.
g) place the html:errors/ (encased in<>) int eh appropriate JSP set by the input attribute (step c). |
|
|
Term
|
Definition
A new feature of Struts 1.1 Formbeans can be declaritively defined in struts-config.xml instead of writing an action form class. a) For a DynaActionForm, the type of attribute of the form beans is always org.apache.struts.action.DynaActionForm. b) A regular ActionForm is developed in Java and declared with the struts-config.xml. With a DynaActionForm there is no validate() method |
|
|
Term
What is a DynaValidatorForm |
|
Definition
An application specific form that can take advantage of XML based validation by virtue of subclassing the validatorForm. The XML based dynamic forms can also avail this feature by specifying the type of form to by DynaValidatorForm. DynaValidatorForm is actually a subclass of the DynaActionForm. It implements the validate() method much like the ValidatorForm and invokes the common validation. DynaValidator Form brings the capability of writing XML based validation rules for dynamic forms too. |
|
|