Introduction to Struts - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Introduction to Struts

Description:

Based on MVC-Model 2 pattern. Apache Jakarta Project. Current release is 1.2.7 ... a form, you will need to extend the class org.apache.struts.action.ActionForm ... – PowerPoint PPT presentation

Number of Views:1598
Avg rating:3.0/5.0
Slides: 20
Provided by: indi1
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Struts


1
Introduction to Struts
2
What is Struts
  • Framework to develop web applications
  • Open source
  • Based on MVC-Model 2 pattern
  • Apache Jakarta Project
  • Current release is 1.2.7
  • Developed in May 2000 and June 2001

3
What is Frame work
  • Frameworks are reusable, semi-complete''
    applications that can be applied to produce
    custom applications
  • Frameworks are tested, proven software designs
    and implementations that reduce the cost,
    accelerate development speed and improve the
    quality of software

4
Benefits of Struts Frameworks
  • Provide developers with modular, reusable and
    extensible software components
  • Modular frameworks reduce the time and effort and
    investment required to understand and maintain
    existing software

5
  • Contributes improvements in programmer
    productivity, as well as enhancing the quality,
    performance, reliability of the software.
  • Reduces the cost of building and maintaining
    software

6
What is the MVC Pattern?
  • MVC was first introduced by SmallTalk
  • The goal of the MVC design pattern is to separate
    the application object (model) from the way it is
    represented to the user (view) from the way in
    which the user controls it (controller) i.e.
    layer architecture.

7
Components within the MVC Pattern?
  • The model provides a representation of the data
    to the components comprising the view. It also
    knows about all the operations that can be
    applied to transform the data.
  • The view provides presentation services in the
    application, such as a data entry screen or a
    screen rendering a query result .

8
  • The controller is responsible for linking the
    view with the model. The controller can be
    thought of as the controlling influence on the
    state of the model. All paths of navigation in
    the application are channelled through the
    controller.

9
What is MVC-Model 2
Business Layer
Controller Servlet
Form submit HTTP Event
Create/Set property
Model JavaBean
Browser
Forward
View JSP HTML Stylesheets
Get property
HTTP Response
10
What is Struts MVC-Model 2
Business Layer
create
ActionForm
Controller ActionServlet
Http Event
Business Logic Action
dispatch
Browser
Struts- Config. xml
create/set
forward
Model JavaBean
Resource Bundle
forward
View JSP
Http Response
get
11
What is Struts Architecture?
  • The model is comprised of a combination of EJBs,
    Java Beans, and a set of Java classes extending
    the Struts base class ActionForm
  • The view is represented by JSPs.
  • The controller is implemented by the Struts
    ActionServlet.

12
  • You can extend the controllers behavior by
    creating Action classes to trigger the execution
    of a user request.

13
How to build a Struts application?
  • Build the Model Components (ActionForm Class)
  • Build the Controller Components (Action Class)
  • Build the View Components (JSPs)
  • Create the struts-config file
  • Update the web.xml file

14
Building an ActionForm
  • The ActionForm (also called the form) is a data
    holder that contains the data entered trough an
    HTML form.
  • The form should also contain the get set
    methods for each property.
  • The form may also implement a validate method to
    perform data entry validations before actually
    performing the requested action.
  • To create a form, you will need to extend the
    class org.apache.struts.action.ActionForm

15
Building an ActionServlet
  • ActionServlet is used to control the request and
    send the appropriate response to that request.
  • It transforms request parameters into ActionForm
  • There is only one ActionServlet in the
    application.
  • Package is used org.apache.struts.action.ActionSer
    vlet

16
Building a JSP
  • To create a JSP using Struts you will use the tag
    libraries provided by the Struts Framework.
  • struts-logic.tld This tag library contains tags
    that are useful in managing conditional
    generation of output text, looping over object
    collections for repetitive generation of output
    text, and application flow management.
  • struts-html.tld This taglib contains tags used
    to create struts input forms, as well as other
    tags generally useful in the creation of
    HTML-based user interfaces.

17
Create the struts-config.xml file
  • To allow for better reusability, all components
    in Struts are loosely coupled.
  • To integrate the components you must create a
    config file (struts-config.xml)
  • Within this file youll define the
    action-mappings and form-beans.
  • The action-mappings tell the ActionServlet which
    action classes to include within the application.
  • The form-beans define the ActionForm classes
    required within the application.

18
Other Resources
  • Struts homepage
  • ttp//jakarta.apache.org/struts/
  • The Jakarta Project
  • ttp//jakarta.apache.org
  • Search on ttp//www.google.com
  • Search criteria jakarta struts

19
  • Thanks
  • Yashwant Chavan.
  • ITShastra (INDIA) Pvt. Ltd.
Write a Comment
User Comments (0)
About PowerShow.com