|
Concepts
The Jakarta Project's Struts framework, version 1.1b2, from
Apache Software Organization is an open source framework for building web applications
that integrate with standard technologies, such as Java Servlets, JavaBeans,
and JavaServer Pages. Struts offers many benefits to the web application developer,
including Model 2 implementation of Model-View-Controller (MVC) design patterns
in JSP web applications. The MVC Model 2 paradigm applied to web applications
lets you separate display code (for example, HTML and tag libraries) from flow
control logic (action classes).
Following is a brief overview of the
MVC Model 2 design pattern. For complete information about how Struts implements
the MVC design patterns, see the Introduction to the Struts User's Guide
on the Jakarta Project's Web site: http://jakarta.apache.org/struts/userGuide/index.html.
-
The Model portion of an MVC-based system
typically comprises JavaBean classes that define the internal state of the
system; they also specify the actions that can be taken to change that state.
If you use the BC4J data access framework, this layer implements the model
entirely for you. Otherwise, you will need to create the classes that implement
your model.
-
The View portion of a Struts-based
application is generally constructed using JSP technology. JSP pages can
contain static HTML (or XML) text called "template text", plus
the ability to insert dynamic content based on the interpretation (at page
request time) of special action tags. The JSP environment includes a set
of custom JSP tag libraries (such as the Struts tag libraries), standard
JSP action tags (such as those described in the JavaServer Pages Specification),
and a facility to install your own JSP custom tag libraries. If you use
the BC4J data access framework, you can take advantage of JDeveloper's JSP
generation wizards and the custom tag libraries that allow your JSP pages
to display databound dynamic content.
-
The Controller portion of the application
is focused on receiving requests from the client (typically a user running
a web browser), deciding what business logic function is to be performed,
and then delegating responsibility for producing the next phase of the user
interface to an appropriate View component. In Struts, the primary components
of the Controller is a servlet of class ActionServlet and the class RequestProcessor.
If you use the BC4J data access framework, the RequestProcessor is extended
for you and is known as the BC4JRequestProcessor.
JDeveloper helps you implement the MVC
Model 2 design patterns using core technology familiar to all web developers:
-
You can create JSP pages with HTML and custom tag libraries to implement
the View of the data. You use links to let the user trigger actions on the
HTTP Request.
-
You can enhance your JSP pages using a large set of custom JSP tag libraries
that work with the Struts framework. All of the Struts tag libraries are
accessible from the JDeveloper Component Palette, when you open a JSP in
the Code Editor. For example, the Struts Form tag works closely with the
Struts actions and form bean to retain the state of a data-entry form and
validate entered data.
-
Unlike non-Struts JSPs, when you run your application, action requests
do not invoke another JSP or Servlet directly. Instead, the request URI
specifies a logical page request, which the request processor (RequestProcessor
class) provided by the Struts controller handles. The Struts servlet may
direct the responsibility for displaying the action results to the appropriate
JSP page of your application, where the page may vary according to the exit
code.
The Struts framework includes custom
JSP tag libraries that you can use to create JSP pages that work with the rest
of the Struts framework objects in your web application:
| Tag library |
Description |
| Struts HTML |
Used to create Struts input forms, as well as other tags generally
useful in the creation of HTML-based user interfaces. |
| Struts Bean |
Useful in accessing beans and their properties, as well as
defining new beans (based on these accesses) that are accessible to the
remainder of the page via scripting variables and page scope attributes.
Convenient mechanisms to create new beans based on the value of request
cookies, headers, and parameters are also provided. |
| Struts Logic |
Useful in managing conditional generation of output text,
looping over object collections for repetitive generation of output text,
and application flow management. |
| Struts Nested |
Brings a nested context to the functionality of the Struts
custom tag library. The purpose of this tag library is to enable the tags
to be aware of the tags which surround them so they can correctly provide
the nesting property reference to the Struts system. |
| Struts Tiles |
Provides tiles tags. Tiles were previously called Components. |
| Struts Templates |
Three tags: put, get, and insert.
A put tag moves content into request scope, which is retrieved
by a get tag in a different JSP page (the template). That template
is included with the insert tag. |
Tags from the various Struts custom
JSP tag libraries appear in JDeveloper on the Component Palette. The JDeveloper
Help system lets you display the Struts Developer's Guide (obtained from the
Apache Software Organization) for specific tags on the palette.
|