...
WebWork is a popular, easy-to-use MVC framework, for . For more information on the WebWork project, please visit WebWork.
This document will help you to get started with WebWork, enabling you to run the examples and demonstrations provided even if you are not an experienced Java web application developer. Nevertheless, WebWork is geared towards developers that have an understanding towards certain technologies. Before diving deeper into how Webwork works, it is recommended that you review the concepts below:
...
You can download the full WebWork distribution here. It contains the webwork.jar file as well as full documentation, sources, all required and optional dependent libraries,and examples. For more information on how to build WebWork from source or even checkout from a clean CVS checkout, please refer to Building Webwork.
...
No Format |
---|
dist/ docs/ lib/ src/ src/java/template/ webapps/ README.txt build.properties build.xml ivy.xml osbuild.xml pom.xml webwork-(VERSION).jar webwork-(VERSION).zip webwork-(VERSION)-src.jar |
The docs directory contains the current Javadocs, the full user documentation including the document you are reading, and taglib documentation, as well as Clover, JUnit and dependency reports for the build.
The dist directory contains a WebWork files with different WebWork packaging:
- webwork-nostatic-<version>.jar: containing only WebWork without the static content
- webwork-static-<version>.zip: containing the required WebWork static dependencies
The lib directory contains the required as well as the optional dependencies Dependencies for Webwork, organized in subdirectories to represent different optional configurations and thereby induced Dependencies:
No Format |
---|
lib/ ajax bootstrap build cewolf default fileupload fileupload-cos fileupload-pell hibernate jasperreports jfree pico plexus portlet quickstart sitemesh source spring tiger tiles velocity xslt |
Note that none of the optional packages are required to use Webwork. If you wish to use certain features such as JasperReports or Java 5 (Tiger) genercis generics and annotation support, you must include the optional packages.
Webwork also comes packaged with all the source files and the templates for the JSP tags.
...
With that, running the demos is as easy as can be. You just need to call:
Code Block |
---|
java -jar webwork.jar quickstart:<application-name> |
from the distribution's top directory, whereby <application-name> is to be replaced by one of the subdirectory names under webapps/, representing the various supplied demo applications. So if you want to start the shopping cart example, just type on your commandlinecommand line:
Code Block |
---|
java -jar webwork.jar quickstart:shopping-cart |
After starting an example in that way, you will simply need to point your browser to http://localhost:8080/shopping-cart to view the results.
...
blank | Not really an example, but a blank web application template for creating your own application |
portlet | Demonstration of WebWork porlet integration (to be deployed in a Portal Server) |
shopping-cart | Nice example application demostrating demonstrating various aspects of WebWork |
showcase | Demonstration of all tag and AJAX features, along with other examples and some best practices |
starter | Basic web application, meant as an easy starting point for experimenting with WebWork's features - one could call it "playground" |
...
See below for a more detailed description of how the blank application helps you to easily create your own WebWork-based applicatiosapplications.
Running Demos with Your Favorite Webcontainer
Anchor | ||||
---|---|---|---|---|
|
Note | ||
---|---|---|
| ||
The previous section described the Quickstart mechanism for trying the supplied example webapps, but Quickstart is also as a handy tool for development of your own WebWork based applications. We recommend you using the said mechanism unless you are familiar with standalone servlet containers and have good reasons to switch, such as preparing a production system etc. |
In order to deploy WebWork applications and demos to your favorite servlet container (also called web container) such as Apache Tomcat or Caucho Resin, you will need to build war files from within the webapps directory. You will find an ant build file there which will provide you with an easy way to accomplish that.
...
Code Block |
---|
ant build -Dwebapp=XXX |
where XXX is the name of the webapp you want to build. After the build is finished, the fully-built war file can be found in the dist directory. You may deploy this file to any servlet container.
For example:
ant build -Dwebapp=showcase
To deploy the built showcase.war to Tomcat, just place it into <TOMCAT_HOME>/webapps/ or use the Tomcat Manager Application to upload and deploy the war. After the war is deployed (and your server is started), point your browser to
http://SERVER:PORT/APPLICATIONNAME, according to your setup and the application you deployed.
...
As said before, the webapps directory contains a blank web application template. It is meant to be left untouched, and instead, you will want to make a copy of it as a starting point for your own new WebWork-based application. Although you can perform such a copy operation yourself, there is a much easier way around: You will find an build.xml in the webapps directory, which if called with ant new will provide you with a fresh empty webapp with a name you will be prompted for.
Setting up from Scratch
Structure of your
...
Web Application
The following illustrates how your web application should be set up. Copy the webwork-(VERSION).jar, all the *.jar files in /lib/default and any necessary optional *.jar files in /lib/(optional configuration) to your webapp/lib directory. If you need to customize your own templates (how HTML is rendered from webwork UI tags), copy the /src/java/template directory into your webapp/ directory. Your webapp should look similar to this:
Code Block |
---|
/mywebapp/ /mywebapp/template/ /mywebapp/META-INF/ /mywebapp/WEB-INF/ /mywebapp/WEB-INF/classes/ /mywebapp/WEB-INF/lib/ /mywebapp/WEB-INF/lib/CORE&OPTIONAL *.jar /mywebapp/WEB-INF/web.xml |
Minimum Set of Libraries and Config Files
...
Filename | Description |
---|---|
webwork.jar | WebWork library itself, found in distribution root directory |
xwork.jar | XWork library on which WebWork is built |
oscore.jar | OSCore, a general-utility library from OpenSymphony |
ognl.jar | Object Graph Navigation Language (OGNL), the expression language used |
commons-logging.jar | Commons logging, which WebWork uses to support transparently logging to |
freemarker.jar | All UI tag templates are written in Freemarker, which is also a good option for your views |
rife-continuations by rife | for the continuations feature |
web.xml | J2EE web application configuration file that defines the servlets, JSP tag |
xwork.xml | WebWork configuration file that defines the actions, results, and interceptors |
The library files (*.jar) needs to be copied to your /mywebapp/WEB-INF/lib/ directory. If you need optional functionalities inducing requiring dependencies to on optional jars, they need to be copied to this directory, too.
Note | ||
---|---|---|
| ||
Before WebWork 2.2, the builtin Inversion of Control (IoC) container was default. Since Spring was has been found doing to do this job much better, the container integrated in WebWorb WebWork / XWork was deprecated. If you would like to follow our recommendation to use Spring as the default IoC container, please make sure to include all jars found in lib/spring in the WEB-INF/lib directory of your application. |
web.xml:
Wiki Markup |
---|
Create the following {{web.xml}} file in {{\[webapp\]/WEB-INF}}. If you already have a {{web.xml}} file, just add the content of the <web-app> tag below to your existing <web-app> tag. |
Code Block | ||||
---|---|---|---|---|
| ||||
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>My WebWork Application</display-name>
<filter>
<filter-name>webwork</filter-name>
<filter-class>com.opensymphony.webwork.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>webwork</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- As of 2.2, Spring is the preferred IoC container rather than XWork,
so you'll have to include the spring jars if you want to use
Spring's IoC capabilities in WebWork. (Thanks Hani for commenting)
If you want to use deprecated integrated IoC container instead, you may
want to omit the following listener configuration.
-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- The following taglib directive would be needed if your servlet container would comply
to Servlet Spec <= 2.2
<taglib>
<taglib-uri>/webwork</taglib-uri>
<taglib-location>/WEB-INF/lib/webwork.jar</taglib-location>
</taglib>
-->
</web-app>
|
This registers FilterDispatcher
to induce enable webwork functionality in for your requests. The ContextLoaderListener will take care of setting up Spring as your IoC container for WebWork. The taglib entry will help you use Tags in your JSP pages.
...
Code Block | ||||
---|---|---|---|---|
| ||||
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.1.1//EN" "http://www.opensymphony.com/xwork/xwork-1.1.1.dtd"> <xwork> <!-- Include webwork defaults (from WebWork JAR). --> <include file="webwork-default.xml" /> <!-- Configuration for the default package. --> <package name="default" extends="webwork-default"> </package> </xwork> |
For now, this xwork.xml does only two things:
...