bof #1820 -- the struts framework community the struts framework community craig mcclanahan
TRANSCRIPT
BOF #1820 -- The Struts Framework Community
The Struts Framework Community
Craig McClanahan
BOF #1820 -- The Struts Framework Community1
Agenda
Welcome Struts 1.1 – New Features What Does The Future Hold? Questions and Answers
Beginning
BOF #1820 -- The Struts Framework Community1
Welcome
The "Struts Community" is growing ... Users (STRUTS-USER mailing list has 1750
subscribers) Downloads (1000/day first two weeks of
March) Plug-in and Add-on technologies Publications and books Awareness (try a Google search on
"struts")
The future looks even brighter
BOF #1820 -- The Struts Framework Community1
Struts 1.1 – New Features
Jakarta Commons Libraries DynaActionForm Declarative Exception Handling Nested Tag Library PlugIn API Multiple Application Support
BOF #1820 -- The Struts Framework Community1
Jakarta Commons Libraries
COMMONS-BEANUTILS Pluggable type converters Mapped properties
contact.phone(Work) DynaBeans
Transparently supported by BeanUtils and PropertyUtils
BOF #1820 -- The Struts Framework Community1
Commons-Beanutils -- DynaBeans
public interface DynaBean {
public Object get(String name);
public Object get(String name, int index);
public Object get(String name, String key);
public void set(String name, Object value);
public void set(String name, int index, Object value);
public void set(String name, String key, Object value);
}
BOF #1820 -- The Struts Framework Community1
Jakarta Commons Libraries
COMMONS-LOGGING Wrapper around any logging API Intelligent discovery mechanism
Did I ask for a particular factory? Use it Is Log4J available? Use it Is JDK1.4 logging available? Use it Default to "no-op" logger
Simple System.err logging implementation available
Relies on underlying logging implementation for configuration
BOF #1820 -- The Struts Framework Community1
Jakarta Commons Libraries
COMMONS-DBCP and COMMONS-POOL Provide javax.sql.DataSource
implementation Connection timeouts Both getConnection() methods supported Idle connections can be released
For backwards compatibility, org.apache.struts.util.GenericDataSource is a wrapper around this
Bridges the JDBC API changes in JDK 1.4
BOF #1820 -- The Struts Framework Community1
DynaActionForm – 1
A common user complaint: writing ActionForm beans is a pain
Now, in many cases you will not have to! Only necessary to provide non-default
reset() and/or validate() methods
Configure the properties and their types in your struts-config.xml file
Transparently supported by all of the existing Struts machinery
BOF #1820 -- The Struts Framework Community1
DynaActionForm – 2
<form-bean name="logonForm"
type="org.apache.struts.action.DynaActionForm">
<form-property name="username"
type="java.lang.String"/>
<form-property name="password"
type="java.lang.String"/>
</form-bean>
BOF #1820 -- The Struts Framework Community1
Declarative Exception Handling – 1
Previously, an Action had to deal with all business logic exceptions itself
Now, you can choose to delegate exception handling to other application resources
Global and per-Action mapping declared in struts-config.xml (like forwards): From a particular Exception class or
superclass To an application-relative path
Requires a small change to your Action to leverage this feature ...
BOF #1820 -- The Struts Framework Community1
Declarative Exception Handling – 2
public ActionForward execute
(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
...
throw new PasswordExpiredException(...);
...
}
BOF #1820 -- The Struts Framework Community1
Declarative Exception Handling – 3
<action path="/logon" ...>
...
<exception key="expired.password"
type="o.a.s.w.e.ExpiredPasswordException"
path="/changePassword.jsp"/>
...
</action>
BOF #1820 -- The Struts Framework Community1
The "Nested" Tag Library – 1
If you ever programmed in Pascal, you might remember the "with" statement ...
Nested tags allow you to establish a default bean for nested property references
1:1 correspondence, and identical functionality, of other Struts tags Except the "name" property gets set for
you automatically ...
BOF #1820 -- The Struts Framework Community1
The "Nested" Tag Library – 2
Before using the nested tags:<bean:write property="address.city"/>
<bean:write property="address.state"/>
<bean:write property="address.zip"/>
After using the nested tags:<nested:nest property="address">
<nested:write property="city"/>
<nested:write property="state"/>
<nested:write property="zip"/>
</nested:nest>
BOF #1820 -- The Struts Framework Community1
Plug-In API
Before, you had to subclass ActionServlet (or define a separate servlet) to initialize application resources at startup time
Now, you can declare a PlugIn that receives notification of application startup and shutdown
public interface PlugIn {
public void destroy();
public void init(ActionServlet servlet,
ApplicationConfig config)
throws ServletException;
}
BOF #1820 -- The Struts Framework Community1
Multiple Application Support – 1
Very popular user request for large scale applications
Design goals: Support multiple independent struts-config.xml
files in the same webapp Sub-applications are identified by an
"application prefix" that follows the context path
Existing Struts-based applications should be able to be installed individually, or as a sub-application, with no changes to the pages, Actions, form beans, or other code
BOF #1820 -- The Struts Framework Community1
Multiple Application Support – 2
Implications of the design goals: "Default" sub-application with a zero-length
prefix (like the ROOT context in Tomcat) "Context-relative" paths must now be
treated as "sub-application-relative" ActionServlet initialization parameters
migrate to the struts-config.xml file Controller must identify the relevant sub-
application, and make its resources available (as request attributes)
APIs must be reviewed for assumptions about there being (for example) only one set of ActionMappings
BOF #1820 -- The Struts Framework Community1
Multiple Application Support – 3
The goals appear to have been achieved: Please download the beta and help us by
testing your apps as sub-applications
Current restrictions: All requests must flow through the
controller – no direct hyperlinks to JSP pages with Struts tags Can be lifted by implementing the controller
as a Filter in Servlet 2.3 Works only for extension-mapped paths to
the controller servlet (*.do)
BOF #1820 -- The Struts Framework Community1
Current Status
Struts 1.1-beta-1 released on March 19, 2002 After the download counts referenced
earlier ... http://jakarta.apace.org/struts/
Please try it out with your own applications, and report any compatibility (or other) bugs: http://nagoya.apache.org/bugzilla/
I anticipate at least one more beta, but there might well be more
It will be released when we're satisfied that it works correctly
BOF #1820 -- The Struts Framework Community1
What Does The Future Hold?
In the mean time, the Java world around web applications is changing ... Servlet 2.4 (JSR-154) JSP 1.3 (JSR-152) JSP Standard Tag Library 1.0 (JSR-52) JavaServer Faces (JSR-127)
And new things are becoming popular ... Web services Portals
BOF #1820 -- The Struts Framework Community1
Servlet 2.4
Some nice additions Request lifecycle events Request dispatcher events
But not likely to affect Struts in the near term
However, is it time to migrate Struts to be based on Servlet 2.3 (and JSP 1.2)? Filters and lifecycle listeners Request and response wrappers JSP Standard Tag Library ...
BOF #1820 -- The Struts Framework Community1
JSP 1.3
Expression Language Available now in JSP Standard Tags
Library In JSP 1.3, can use in all tag attributes, as
well as in template text We can help the transition by supporting
this in Struts tags
JSP Fragments Create parameterized "custom actions"
BOF #1820 -- The Struts Framework Community1
JSP Standard Tag Library
Currently in beta, will be final in June RI implemented at Jakarta
http://jakarta.apache.org/taglibs/
Core library has familiar functionality URL, XML, and I18N tags also very useful Expression language allows for much
simpler tags JSP containers can optimize performance Struts users should definitely plan
on utilizing these tag libraries
BOF #1820 -- The Struts Framework Community1
JavaServer Faces – 1
The most popular question at JavaOne this year: What's the deal with Struts and
JavaServer Faces?
The short version of the answer: JavaServer Faces will be a useful
mechanism to build the UI for Struts-based web applications
For the longer version of the answer, let's go back into history for a moment ...
BOF #1820 -- The Struts Framework Community1
JavaServer Faces – 2
Where did Struts come from? Two years of discussion about MVC and
Model 1 versus Model 2 My experience building a large scale web
application that was fully internationalized The key feature – separation of concerns
The key technologies enforcing separation Logical name mappings in struts-config.xml View --> Controller encapsulated in a form
submit, matched to a form bean Controller --> View via RequestDispatcer
BOF #1820 -- The Struts Framework Community1
JavaServer Faces – 3
Where is JavaServer Faces coming from? The need to provide rich UI components
to page developers The need for a standard set of
components to ease learning (and enable tools support)
But UI components are not enough by themselves: Event handling Validation Navigation
There needs to be enough there to beusable out of the box
BOF #1820 -- The Struts Framework Community1
JavaServer Faces – 4
So what do we do about the overlap? Use the parts that are helpful, ignore the
parts that are not
The ideal scenario: Struts provides a JSF-compliant tag library
that provides the functionality we know and love Context-relative paths, URL rewriting, ...
Struts applications can migrate their UI to use Faces, one page at a time, with no changes to the Actions, form beans, or business logic
This is an entirely feasible endgame We're just not done yet ...
BOF #1820 -- The Struts Framework Community1
Questions and Answers
Phew, that's a lot of information ... So, what's on your minds?
BOF #1820 -- The Struts Framework Community