Configure the Action, ActionForm and Forward in the Struts Configuration File

In this section, We will learn how to configure the subclass of Action & ActionForm and Forward the request to next view page.


All Action subclasses and subclasses of ActionForm must be configure into struts-config.xml.
The struts framework provides some rules and tags to configure it.
Forward must be configure with in tags.


 Note :- The value of path attribute of tag must be same as action attribute. eg..The input attribute of tag consist the name of Input JSP View.

Scope attributes :- The scope attribute is used to define scope for request or session . The type attribute is fully qualified name of Action subclass. 

Validate attribute :-The validate attribute is for enable/disable the for check form validation. 

name attributes :- The name attribute is used to tell controller for lookup the name of action form to store input data. The value of name attribute must be same as appropriate name attribute. We can configure more than one Action within tag. To configure Forward struts provides tag. 
This tag has two attributes name and path.
The value of name attribute is the key which will matched with key returned by appropriate action subclass and this value is used to forward to next view (to the value of path attribute).
We can configure more than one forward with in tag. Struts provides tag to configure the subclass of ActionForm. tag have two attributes name and type .The type attribute is fully qualified name of subclass of ActionForm and the name is through which controller lookup to store the data coming for Input JSP
View. 
We can configure more than one ActionForm with in tag. Following source code will explain more:-
SourceCode:


  <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd">  
  <struts-config>
  <form-beans>
  <form-bean name="InputForm" type="wisedeveloper.co.in.InputForm" /> 
  </form-beans>
  <global-exceptions />
  <global-forwards />   
  <action-mappings>  
  <action input="/input.jsp" parameter="method" name="InputForm" path="/inputAction" scope="session" type   =  " wisedeveloper.co.in.InputAction">  
  <forward name="success" path="/success.jsp" /> 
  </action>
  </action-mappings>  
  <message-resources parameter="wisedeveloper.co.in.ApplicationResource" /> 
  </struts-config>

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More