Struts 1.1 Controller Uml Diagrams

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Struts 1.1 Controller Uml Diagrams as PDF for free.

More details

  • Words: 1,059
  • Pages: 8
Struts 1.1 Controller UML diagrams

Last update : 19/12/2003

back to HOME PAGE

Introduction The goal of this article is to illustrate the Struts 1.1 Controller with UML diagrams. This article is an introduction to the Struts framework in order to help beginners programmers to understand the MVC model 2.

Contents : 1. 2. 3. 4. 5.

Context description of the example with the struts-config.xml file Struts 1.1 Controller Class Diagram of the org.apache.struts.action Sequence Diagram Links about Model View Controller model 2 pattern and the Struts implementation. Use my diagrams - the license to respect if you want to use the code

To print the figures of this article, configure your printer in landscape mode.

back to Top

1. Context description In order to show how to use the Struts framework classes, I have designed some diagrams starting from a simple example : a client submits a form to a "forwarded" page :

struts-config.xml This is the configuration resource file - which is parsed by the Struts Controller for initialization.

back to Top

2. Class diagrams

Note I have forgotten the association between the Action class and the ActionServlet. I will update the diagram after the summer ...

Application config, org.apache.struts.config package ModuleConfigImpl contains a collection of static configuration information that describes an application module. For application initialization, struts-config.xml is

parsed in order to dispatch mapping information in instances of ActionConfig, ForwardConfig and FormBeanConfig. •

Mapping management : o ActionConfig contains information of how specific events are mapped to Actions classes.  path is a request URI path used to select this mapping. Example in the jsp page :
 type is the Action class name which can handle the event  name is the name of the form bean, if any, associated with the action.  scope is the JSP scope (application, session, request, page) within which the form bean will be created

Example in struts-config.xml : ActionMapping extends ActionConfig and is not deprecated because of backward compatibility with version 1.02. o



ForwardConfig encapsulates where the user will be sent to. Properties

name and path correspond to the strut-config.xml line : . ActionForward extends ForwardConfig and is not deprecated because of backward compatibility with version 1.02.

ActionForm beans management : o FormBeanConfig is a definition of ActionForm beans loaded from strutsconfig.xml : o FormPropertConfig is a JavaBean representing the configuration information of a element in struts-config.xml :

The parsing is done by using the famous jakarta Digester, which is a powerful component of XML - java objects mapping.

Struts Controller The ActionServlet class is the core of the framework. It is an HTTPServlet which receives requests from the browser and forwards it depending on a configuration file : strutsconfig.xml. •

Since Struts 1.1, the processing logic has been delegated to the RequestProcessor class : o Method processMapping selects the ActionConfig used to process the selection path for this request.

o o o o

Method processActionForm retrieves the ActionForm associated with a mapping or creates and stashes one if necessary. Method processPopulate populates the properties of the specified ActionForm from the request parameters included with this request. Method processValidate calls the validate() method of the specified ActionForm, and forwards back to the input form if there are any errors. Method processActionPerform asks the specified Action instance to handle the request, returns an ActionForward

The subclasses of Action are created and used by RequestProcessor. It is a wrapper around Business logic. To use Action, subclass it and overwrite the execute() method. o

o

Method execute processes the HTTP request, and creates the corresponding HTTP response. Returns an ActionForward instance describing where and how control should be forwarded. Method saveErrors saves the specified error messages keys into the appropriate request

HTML Form management • • •

ActionForm represents a general concept of data that is set or updated by a HTML Form. Struts will automatically set the state of the DynaActionForm using

the corresponding fields from the HttpServletRequest. DynaActionForm is Specialized subclass of ActionForm that allows the creation of form beans with dynamic sets of properties, without requiring the developer to create a Java class for each type of form bean. DynaActionFormClass is used by DynaActionForm to manage its internal state.

Nb : You can still define your own ActionForm in the Struts 1.02 way, by sub-class ActionForm.

User classes • • •

HelperBean is a "Helper" class, it is a value object bean which holds the data

required by the screens. UserAction is a typical Action, inherits the Struts Action class. UserDelegate is based on the Business Delegate pattern. This is an intermediate class which decouples business components from the code that uses them, encapsulates business services and access to the Model. See the Struts User's guide to understand what a Model is in the MVC model 2 pattern.

forwardedPage.jsp is not a class, it is the targeted jsp page. represents the View in the Model view Controller model 2 pattern.

Error management

• • • •

ActionMessages is a collection of ActionMessage ActionMessage encapsulates an user message, contains a message key for I18N management (Internationalization) and 4 objects for parametric replacement in the message text) ActionErrors extends ActionMessages is a collection of ActionError ActionError encapsulates error messages

back to Top

3. Sequence Diagram

Messages Description • • •

1 the client submits an HTML form, doPost method is called to allow the the HtppServlet ActionServlet to handle the POST request 1.1 The Struts Controller ActionServlet delegates to RequestProcessor the process of the request RequestProcessor does the following actions :

1.1.1 retrieve and return the ActionForm bean associated with the mapping, creating one if necessary o 1.1.2 populates the ActionForm bean with the input fields of the HTML form o 1.1.3 validates the input field values and creates error messages if validation errors o 1.1.4 acquires an UserAction instance to process the request, calling the overwritten execute method of UserAction  1.1.4.1 retrieves data from the UserActionForm bean by getProperties methods  1.1.4.2 calls business services through the BusinessDelegate  1.1.4.3 populates a value object bean (optional)  1.1.4.4 forwards to the specified destination in struts-config.xml The forwarded page retrieves data from : o 2 the HelperBean o 3 and / or from the ActionForm bean o


Related Documents

Uml Diagrams
November 2019 46
Uml+use+case+diagrams
November 2019 34
Uml 11
November 2019 3