Introduction to Jakarta Struts Framework - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Introduction to Jakarta Struts Framework

Description:

... writers the ability to fashion their web applications using the ... Web designer can learn how to program in MVC. ???? http://jakarta.apache.org/struts ... – PowerPoint PPT presentation

Number of Views:225
Avg rating:3.0/5.0
Slides: 27
Provided by: try3
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Jakarta Struts Framework


1
Introduction to Jakarta Struts Framework
  • Try
  • NCCU Computer Center
  • Mar 20,2002

2
The Evolution of Server Side Web Ap Developement
  • CGI(or ISAPI)
  • Servlet
  • JSP
  • JSPBean (Model 1)
  • JSPBeanXML techs
  • Model 2 (MVC)
  • Model 2X(MVC with XML techs)

3
What is MVC
  • The Model View Controller is a technique used to
    separate Business logic/state (the Model) from
    User Interface (the View) and program
    progression/flow (the Control).
  • This pattern is very useful when it comes to
    modern web development
  • The majority of modern, high usage websites are
    dynamically driven.
  • People well skilled at presentation (HTML
    writers) seldom know how to develop back-end
    solutions and visa versa.
  • Separating business rules from presentation is
    good no matter what environment you develop in be
    it web or desktop.

???? Craig W. Tataryn ,Introduction to MVC and
the Jakarta Struts Framework
4
(No Transcript)
5
Benefits of MVC
  • Promotes Modularity
  • I18n
  • Abstraction
  • Allows application to be defined in a flow-chart,
    use-case or activity diagram which is more
    easily transferred to implementation.

???? Craig W. Tataryn ,Introduction to MVC and
the Jakarta Struts Framework
6
The Struts Framework overview
  • Struts is an open source MVC framework developed
    by the Apache Jakarta project group.
  • Struts allows JSP/Servlet writers the ability to
    fashion their web applications using the MVC
    design pattern.
  • By designing your web application using Struts
    you allow
  • Architect the ability to design using the MVC
    pattern
  • Developer to exploit the Struts framework when
    building the app.
  • Web designer can learn how to program in MVC.

???? http//jakarta.apache.org/struts/
7
The Struts Framework overview(2)
  • Struts takes much difficult work out of
    developing an MVC based web app.
  • The Struts framework provides a collection of
    canned objects which can facilitate fundamental
    aspects of MVC, while allowing you to extend
    further as need suites

8
Components of Struts Framework
  • Model
  • Business Logic Bean(or session bean)?StateBean(or
    entity bean)?ActionForm?
  • View
  • A Set of Tag library.
  • Language Resource File
  • Controller
  • ActionServlet( controlled by struct-configs.xml)
  • ActionClasses
  • Utility Classes

9
Components of Struts Framework(2)
???? http//www-106.ibm.com/developerworks/library
/j-struts/?n-j-2151
10
How Struts works
???? http//www-106.ibm.com/developerworks/library
/j-struts/?n-j-2151
11
View
  • The view in Struts is represented by JSP pages.
  • Minimize the occurance of scriptlets in your page
  • Use the tag-library provided by Struts to control
    the presenatational logic.

12
ViewI18n
  • The ability to maintain a web app in several
    different languages
  • Based on the language setup on the client side,
    the web app will automatically switch.
  • This is achieve in Struts through Java Resource
    Bundles
  • Instead of having to make a ResourceBundle class
    for each language supported by your web app,
    resource bundles can be described as language
    resource files

13
Demo
Traditional Chinese
English
14
ViewI18n(2)
  • Language Resource
  • FileName Conventions
  • (ResourceName)_(ISO-LanguageCode)_(ISO-ConturyCod
    e).properties
  • Register the Resource Name in web.xml.
  • In order for web developers to get at the string
    resources we use a special Struts tag called
    ltbeanmessage/gt

15
ViewExample
  • Login.jsp
  • ApplicationResources_en_US.properties
  • ApplicationResources_zh_TW.properties

16
Model
  • ResultBean,hold information needed to generate
    the result page.
  • FromBean(extend ActionForm ),hold the data passed
    by user either by POST or Query String.
  • Business Logic Bean.
  • EJB ?JMS or other components we impl at business
    logic layer before.

17
ModelActionForm
  • JSP pages acting as the view for this LogonForm
    are automatically updated by Struts with the
    current values of the UserName and Password
    properties.
  • If the user changes the properties via the JSP
    page, the LogonForm will automatically be updated
    by Struts
  • Before an ActionForm object is passed to a
    controller for processing, a validate method
    can be implemented on the form which allows the
    form to belay processing until the user fixes
    invalid input

18
ModelExample
  • LoginForm.java
  • tw.edu.nccu.user.TeacherData

19
Control
  • The controller is the switch board of MVC.
  • It directs the user to the appropriate views by
    providing the view with the correct model
  • The task of directing users to appropriate views
    is called mapping in struts.
  • The Struts framework provides a base object
    called org.apache.struts.action.ActionServlet.
  • The ActionServlet class uses a configuration file
    called struts-config.xml to read mapping data
    called action mappings
  • The ActionServlet class reads the incoming URI
    and tries to match the URI against a set of
    action mappings to see if it can find a
    controller class which would be willing to handle
    the request

20
Controller (2)
http//TeacherStudata/login.action
Server configured to pass .action extensions to
org.apache.struts.action.ActionServlet via a
web.xml configuration file
ActionServlet object inspects the URI and tries
to match it against an ActionMapping located in
the struts-config.xml file.
Instance of appropriate Action class is found and
its perform() method is called
Action object handles the request and returns
control to a view based where the user is
within the flow of the application
21
ControlExample
  • tw.edu.nccu.teacherstudata.actions.LoginAction
  • Struts-config.xml
  • LoginAction.java

22
Problems with Struts
  • Does not work on JDK1.4.0
  • Steep learning curve.
  • Problems on old Application Servers(include
    Tomcat3.2.1 ?Weblogic 5.1).
  • The only output document is HTML,it didnt
    support the XSL transform technology.(Unless we
    modify the source code)

23
Model 2X
  • Model2X
  • Conceived by Julien Mercay and Gilbert Bouzeid on
    Feb 1,2002.
  • Replace the JSPTagLib with XMLXSLT at
    presentation layer.
  • Using XSL Servlet as the Document Factory.
  • Support pipe-line processing while generating the
    target document.

24
(No Transcript)
25
(No Transcript)
26
Resource
  • Struts homepage
  • http//jakarta.apache.org/struts/
  • Suns Servlet Specification
  • http//java.sun.com/products/servlet/download.html
    specs
  • Suns JSP Specification
  • http//java.sun.com/products/jsp/download.html
  • Blue Stones Struts Tutorial
  • http//developer.bluestone.com/scripts/SaISAPI.dll
    /Gallery.class/demos/trailMaps/index.jsp
  • My Struts page
  • http//java.cc.nccu.edu.tw/struts/
Write a Comment
User Comments (0)
About PowerShow.com