Currently, the Java development front is split into two main areas: Web development and Swing client-side GUI development. The Swing developers use the excellent Swing toolkit and core Java APIs for the majority of their GUI development needs. Java Web developers also use core Java APIs, but in addition they use frameworks. Most of the enterprise-level, Web-based projects use some sort of an architecture that includes at least one framework. Why? This is because frameworks greatly simplify development and design of the project, decrease time to production, reduce amount of labor and code needed, and improve application performance. I've described several major frameworks in my previous article "Modern Frameworks for Web Development."
This article will concentrate only on WebWork. I will show how to set up WebWork using enterprise-scale tools such as JBuilder 2005 and BEA WebLogic and, as an example, create a sample application that uses some of WebWork's features. I will assume you have WebLogic (or a comparable application server) installed and configured and are familiar with JBuilder IDE. Because WebWork is J2EE-compliant, other application servers, such as Apache Tomcat can be used as well.
Every framework for Web developments by design serves a specific purpose. It could be a Model-View-Controller implementation with Inversion of Control logic for coordination of client to server requests and actions on the server, separation of business logic from view layer, or Java to SQL mapping to abstract interaction with database layer. Also, it could be client data validation and view abstraction via custom framework tag libraries and JSTL (Java standard tag libraries).
WebWork is a Model-View-Controlled type of framework. This means it separates logic from view and simplifies Web development by using a powerful "action" concept on the server side.
It is built on top of a command pattern framework API called XWork. WebWork specific features include: dispatchers that handle/delegate requests; result types that support several view technologies (JSP, Velocity, JasperReports, XML, FreeMarker); and a small but powerful library of JSP tags and Velocity macros. Dispatchers invoke specified XWork actions that access and manipulate the model and provide easy access for the view to display model data.
Setup Server Environment in JBuilder
To get started with WebWork, download it here: http://www.opensymphony.com/webwork/download.action.
In JBuilder 2005, configure an enterprise server to point to your BEA WebLogic installation. If you are using a different app server, the setup should be similar. The WebLogic domain and server should be set up and are beyond the scope of this article. Skip this section if you already have configured any application server in you IDE.
- Choose Enterprise|Configure Servers.
The Configure Servers dialog box appears. (See below)
- Select the WebLogic server 8.x by clicking it in the pane on the left. The right side of the dialog box lists the default settings for the selected server.
- Check the Enable Server check box at the top of the dialog box. Checking this option enables the fields for the selected application server. You won't be able to edit any fields until it is checked. The Enable Server check box also determines whether this server will appear in the list of servers when you select a server for your project using the Servers page of the Project|Project Properties dialog box.
JBuilder provides default settings for the selected server. If JBuilder's default settings are not appropriate, edit any of the settings as needed. Some servers require you to enter settings in addition to the defaults. Clicking the OK button in this dialog box when not all required values are set or selecting another server while the current one is enabled displays a message dialog box that informs you about the missing settings.
- If you want to change any of the settings, click the ellipsis (...) button next to the field and make your changes. Assuming you installed WebLogic Platform 8.1 into a BEA_HOME directory with the name bea, your home directory should be [drive]:/bea/weblogic81/server.
- Click the Custom tab to view fields unique to the server. Change or fill in these fields:
- Home Directory: The BEA Home Directory is the directory into which you installed the WebLogic Server and that contains the registry.xml file. JBuilder assigns a default value for the BEA Home Directory that varies depending on the version of the WebLogic Server installed.
- JDK Installation Directory: For WebLogic Platform 8.1, the directory is <beahome>/jdk142_05.
- Domain Directory: Use the ellipsis (...) button to select a directory as your domain directory. The domain directory is the directory where your WebLogic domain is stored. For WebLogic 8.1, it is user_projects/domains/mydomain. Setting the domain directory sets the working directory value on the General page. For more information about WebLogic domains, see your WebLogic documentation.
- User Name: The user name you use to authenticate yourself to the server.
- Password: The password you use to authenticate yourself to the server.
- Server Name: The name you specify is used as a VM parameter for starting the server. JBuilder suggests a default name of "myserver."
- Listen Address: Specifies a listen address for this server. The host value must be either the DNS name or the IP address of the server. If you do not specify a Listen Address, the server uses either the machine's DNS name or its IP address.
- Listen Port: Specifies the non-SSL listen port for this server. If you do not specify a Listen Port, the server uses 7001 as the default.
- Version: Should be SP4 at least or higher
- Add An Admin Console Item To The Enterprise Menu: Checking this check box adds the WebLogic Admin Console item to JBuilder's Enterprise menu. You must also fill in the next field, Web Browser Path, to have the menu item added.
- Web Browser Path: Specify the path and file name of the Web browser of your choice. For example, you might specify c:/program files/Internet Explorer/iexplore.exe if you want to use Microsoft's Internet Explorer.
- Add A Configuration Wizard Item To The Enterprise Menu: Adds a WebLogic Configuration Wizard item to the JBuilder Enterprise menu. When you select this menu item, the BEA WebLogic Configuration wizard begins, which guides you through the steps of configuring the domain for your use.
- Use External Compiler: Leave default
Set up the project with WebWork
To show the WebWork framework in action, I created a sample project "WebWork" in JBuilder. To the project libraries (under project properties), I added WebWork jars. The main jar as of this writing is version 2.1.7 I placed and all other libraries in WebWorkLibs and WebWorkOptionalLibs folders.