Recommended Links

FLIPKART ASSURED STORE

Royal Oak Entertainment Unit (Dark Finish)     Amazon-GREAT INDIAN FESTIVAL



Our Advertising Partners

Sunday 21 August 2011

Struts (Part1)

   
Introduction to Struts(Short note)

The Struts framework is written entirely in Java using standard J2EE APIs. In addition, it uses several well-known J2EE design patterns, such as Model-view-controller and FrontController.



Model-view-controller (MVC)

Model-view-controller (MVC) is a design pattern that defines a clear separation between the following three application tiers:

The model is the set of data and business rules for the application. This is commonly called the application's business logic.

The view is the application's user interface.
The controller defines the way that an application interacts with user input and the model. This is called the application logic.

By promoting a clear separation between tiers, MVC allows loose coupling between components that comprise each tier. This allows more flexibility and code reuse. For example, if you develop several user interfaces for one application, you need to develop the view component because of the loosely coupled application tiers.

The Struts framework is the View and Controller components of MVC. The following shows how Struts maps to the MVC framework. Struts has three major components:

  •   Action beans
  •   ActionServlet 
  •   ActionForm beans and custom tags.                                                                                                       
   MVC and the Struts framework

  
Action beans and ActionServlet

Struts provides a single ActionServlet ( org.apache.struts.action.ActionServlet ) to handle all browser requests. This type of framework is called the FrontController pattern. Each browser request is handled by the Struts Action subclass (subclass of org.apache.struts.action.Action ). Each browser request is mapped to an Action subclass in the struts-config.xml file. The ActionServlet loads the mapping during initialization. To configure the Web project to pass all browser requests to the ActionServlet , map all URIs that end with .do (for example, *.do) to the ActionServlet in the Web deployment descriptor. You can then provide the actual Action subclass mappings in the Struts configuration file for individual request URI, such as /submit.do.


ActionForm beans

Browser requests can come with parameters. When a user submits a HTML form, the Struts framework encloses the parameters in an org.apache.struts.action.ActionForm bean. You can also use the ActionForm bean to pre-populate a form with default values that are obtained from database or other backend systems. If the user enters incorrect values in the form, the ActionForm may perform validations. You can re-display the form with the previous input.


Custom tags

Struts provides a large set of JSP custom tags that support the ActionForm beans. The custom tags support:
Pre-population of a HTML form with values taken from an ActionForm subclass.
Internationalization, such as providing text that is determined by the user's locale.
Logic, such as showing a different title for a page based on how it is used




For Sample Application + Source Code + Video tutorial

You can download it from following url:

http://www.4shared.com/account/dir/9j1AUuwl/_online.html#dir=107444956

1. Struts_Login_Application.exe

2. i18nsource_Struts.exe



Regards, 

Gaurav 


Note: Please note that data provided above is only summary of my search and for more detailed 
          description (if anyone wants), please leave comment below or mail_me at gsingh4g@gmail.com

No comments:

Post a Comment