Home > Articles

WebLogic Workshop Application Development Basics

  • Print
  • + Share This
This chapter is from the book

by Albert J. Saganich, Jr.

In This Chapter

  • WebLogic Workshop Programming Basics

  • Creating Applications and Projects

  • Deploying and Configuring Applications

WebLogic Workshop Programming Basics

WebLogic Workshop (WLW) is a full-featured development environment that allows developers to build enterprise applications, Web applications, individual components, Enterprise JavaBeans (EJBs), or any combination of these elements. This chapter explores the WebLogic Workshop programming model and introduces enterprise application development. Specifically, WebLogic Workshop allows you to

  • Create WebLogic Workshop applications.

  • Create WebLogic Workshop projects supporting portals, integration, controls, EJBs, Web Services, and XML Schema.

  • Create traditional Web applications using Page Flow for page navigation and Form beans for data gathering and display.

  • Create portal applications that can be the basis for a custom look and feel as well as personalization and other portal features.

  • Create integration applications that can be the basis for business process modeling, data transformation and integration, and multiparty orchestrated messaging.

  • Create and use simple controls and Web services.

The WLW Programming Model and Structured Programming

Before you can develop applications with WebLogic Workshop, you must understand the Workshop programming model, shown in Figure 3.1. WebLogic Workshop applications are separated into a number of different layers. The topmost level of a Workshop application, the external interface layer, provides methods for accessing an application. Application functionality can be accessed traditionally, typically by using a browser, through portal or Web applications, or directly using Web services or business processes via Web services.

Figure 3.1Figure 3.1 The WebLogic Workshop programming model.


Business Process

For those unfamiliar with the term, a business process performs a well-defined set of business operations to complete some task. A business process definition is a programmatic construct that models a business process. WebLogic Workshop provides a mechanism for defining business processes in the Integrated Development Environment (IDE) known as a Java Business Process Definition (JPD). WebLogic Workshop business process definitions are discussed in Chapter 11, "Working with Workflows."

The second level of the model shows the controls layer. Web applications, portals, and other applications access resources or business logic using various controls. Controls, a new concept introduced with WebLogic Workshop 1.0 and improved greatly with 8.1, provide an abstraction layer that simplifies the process of working with Java 2 Enterprise Edition (J2EE) or custom resources. Controls are completely integrated into the WebLogic Workshop IDE, and much of the application code, regardless of what the application makes available, is dedicated to working with controls in one fashion or another.

Controls are a revolutionary step forward for application developers and component developers. For the consumer, controls provide both an IDE-based facade and a runtime behavior for accessing functionality. Workshop controls enable developers to access resources and business logic in a consistent, straightforward manner, as though the control is a simple Java object. Controls simplify interaction with resources by providing a common interface to all resources.

For the developer, controls are Java classes annotated with Javadoc tags that integrate seamlessly into WebLogic Workshop. These Javadoc tags, along with specific file extensions, allow WebLogic Workshop to recognize a class as a control. The developer of a control, whether the control is packaged with WebLogic Workshop or custom developed, makes a set of core functionality available via standard Java methods. At runtime, the WebLogic Server engine creates instances of the control during the consuming application's life cycle. The runtime engine sets up and tears down the background instance, as required. As a result, all the drudgery and issues of accessing J2EE resources are hidden behind the control interface.

JSR175 As a Definition of Class Metadata

The use of Javadoc annotations to provide metadata is currently being standardized and reviewed as part of Java Specification Request (JSR) 175, "A Metadata Facility for the Java Programming Language."

The application developer needs to know only the simpler aspects of the Java language, and most method calls are handled in a sequential, rather than object-oriented, fashion. Figure 3.2 shows how workshop applications interface with controls. Annotations exist at the file, field, and method levels and apply to a variety of file types. Although WebLogic Workshop handles most annotations, knowing what annotations are and are not is helpful. These are the most common annotations:

  • @jc:<tagname>—Annotations for Java controls

  • @jpd:<tagname>—Annotations for Java business processes

  • @jpf:<tagname>—Annotations for Java Page Flows

  • @jws:<tagname>—Annotations for Web services

  • @common:<tagname>—Annotations for common features

Figure 3.2Figure 3.2 The WebLogic controls model.


WebLogic Workshop provides two specific control types: Java controls, defined with a .jcs extension, that developers write to provide business logic and access other controls for creating logical units of business functionality, and resource or extensible controls, defined with a .jcx extension, which act as wrappers for traditional J2EE resources. In either case, a control can be used in page navigation, Web services, business processes, or from within another control.

The lowest layer in the WebLogic Workshop programming model is the resource access layer. Resource controls are purchased from third-party vendors and used directly to access the functionality of resources based on the WebLogic Workshop wizards or to access J2EE functionality. WebLogic Workshop comes packaged with a large variety of controls, all ready to use directly out-of-the-box. Examples of packaged controls include the following, which are only a small subset of the available controls:

  • Database and Rowset controls providing support for easy access to existing databases

  • Message-oriented controls for simplifying interactions with messaging-oriented middleware, such as Java Messaging Service (JMS)

  • Business process (workflow) controls for defining and interacting with business processes

  • EJB controls designed to simplify accessing existing EJBs

  • Web services controls for creating and accessing existing Web services

  • Application view controls for simplifying access to underlying J2EE Connector Architecture (J2CA) adapters

  • Third-party controls, including controls provided by partners and other interested parties

Resource controls come in two types: those used directly by dropping instances into your application and manipulating their properties, and those that you custom-configure using wizards. The rowset control is an excellent example of a custom-configured (not "developed") control. Using the RowSet Wizard, you can specify the database schema and table you need to access, and the wizard creates a class that encapsulates all the logic to access the specified database table using java.sql.Rowset objects.

Page Flow Fundamentals

Figure 3.1 depicted a high-level overview of how WebLogic Workshop applications are structured from a data access and logic perspective. However, when viewed from a navigation perspective, a Workshop application looks different. Figure 3.3 shows Workshop applications from a Model-View-Controller (MVC) perspective. Behind the scenes, Workshop applications use a Struts-based implementation to provide the presentation and Controller functionality known as Page Flow. In Workshop applications, controls provide the Model component and Page Flows provide the View and Controller components.

Figure 3.3Figure 3.3 The Model-View-Controller view of a Workshop application.


Page Flows enable developers to quickly, easily, and (perhaps most important) visually define page transitions between pages of an application. Page Flows are defined within a Page Flow Controller, indicated with a .jpf extension, as well as HTML and JSP pages. Pageflows representing the controller aspect of MVC applications, controls the model and HTML and JSP presentation. Figure 3.4 shows the Flow View for the simple entry page of the Wonderland Casino. Wonderland offers a number of services, including gaming, eating, accommodations, and relaxing.

Figure 3.4Figure 3.4 A simple Page Flow in Flow View.


Fundamentally, a Page Flow is composed of a presentation component via JSP or HTML, data made available through controls, and decision logic accessible through actions. These areas are managed using three specific constructs:

  • Form beans—Capture page data and are provided as input to Actions. Form beans are contained within Page Flows as JavaBean inner classes.

  • Actions—Contain Java code implementing navigation logic, provide access to resources via controls, and use form data via Form beans. Actions are implemented as Controller methods, and the Page Flow engine can pass Form beans to them as input.

  • Forward objects—Define and manage passing navigation control from actions to subsequent pages.

A fourth, and often overlooked, area of Page Flows is that of initial page population. Before users can make any decision about what page to move to next, they often need some data. Pages can display data based on Page Flow variables and Form beans, using a combination of NetUI JSP tags and XScript. NetUI tags are closely integrated into Page Flow and described in detail in Chapters 4, "Developing with Page Flow," and 6, "Introduction to WebLogic Workshop Controls and Components." In Page Flows, XScript is used as a mechanism for accessing variables. XScript expressions can be written to navigate arrays of data or arbitrary XML. Listing 3.1 shows the JSP page representing the starting point of the Wonderland Casino. The netui anchor tags shown in the second and third shaded code lines in Listing 3.1 render visually as URL links but provide the name of the action that the Controller should call when they're clicked. The first shaded code line shows an XScript expression accessing a pageFlow variable.

Opening and Building Chapter 3 Source

The complete source for the Chapter 3 examples can be found on the CD accompanying this book. To examine, build, or run the example, choose File, Open, Application from the WebLogic Workshop menu, or double-click the .work file in the exampleWebapp directory.

Listing 3.1 The index.jsp Page

<!--Generated by WebLogic Workshop-->
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
<%@ taglib uri="netui-tags-html.tld" prefix="netui"%>
<%@ taglib uri="netui-tags-template.tld" prefix="netui-template"%>

 <netui:html>
  <head>
    <title>
       <netui:label value="{pageFlow.mainTitle}"/> Main Page.
    </title>
  </head>
  <body>
    <p>

  <h1><center> Welcome to the <netui:label value="{pageFlow.mainTitle}"/> .
  </center></h1>
  <table border="1">
    <tr>
      <td>Would you like to:</td>
    </tr>
    <tr>
      <td>
      <netui:anchor action="gamble">
      Try your luck at our tables of chance and skill!</netui:anchor>
      </td>
    </tr>
    <tr>
      <td>
      <netui:anchor action="relax">Relax in out fine spa!</netui:anchor>
      </td>
    </tr>
  </table>
  
  </body>
</netui:html>

Listing 3.2 shows portions of the Controller pictured in Figure 3.5. Examining Listing 3.2, you can see that the first line in the shaded code section defines the String variable used by index.jsp to display the main page caption. The netui:label JSP tag displays text and can take input from a variable via the datasource attribute—in this example, the parent pageFlow variable mainTitle is used as the datasource. Two actions are defined in the shaded code section: begin and gamble. Examining the gamble action, you can see that the @jpf:forward annotation defines the page that the success operation should forward to on success. When the forward object is created, the @jpf:forward annotation directs the forward object to the Gambling.jsp page. All this code is created automatically when WebLogic Workshop is used to create the Page Flow.

Listing 3.2 Portions of Controller.jpf

import com.bea.wlw.netui.pageflow.PageFlowController;
import com.bea.wlw.netui.pageflow.Forward;
/**
*
 * @jpf:controller
 * @jpf:view-properties view-properties::
 * <!-- This data is auto-generated. Do not hand-edit this section. -->
. . .
 */
public class Controller extends PageFlowController
{
  public String mainTitle ="Wonderland Casino";
  

  
  /**
   * @jpf:action
   * @jpf:forward name="index" path="index.jsp"
   */  
  protected Forward begin()
  {
    return new Forward("index");
  }


  /**
   * @jpf:action
   * @jpf:forward name="success" path="Gambling.jsp"
   */
  protected Forward gamble(GambleForm form)
  {
    return new Forward("success");
  }
...
 /**
  * FormData get and set methods can be overwritten by the Form bean editor.
  */
  public static class GambleForm extends FormData
  {
    private String bet;
     private String table;

   public void setTable(String table)
    {     this.table = table;
    }

   public String getTable()
    {
      return this.table;
    }

...
}

Form beans are the most commonly used mechanism for gathering data from a page. To create them, you use the Form bean editor in Workshop. A Form bean can be added to a page by dragging a netui:form tag onto a JSP and then associating it with a Form bean. When a user clicks the Form button, the data is packaged up and provided to the action. Figure 3.5 shows the Action View of a simple Controller using a Form bean. The index page contains a NetUI form element that gathers gambling data. When the form's Gamble button is clicked, the GambleForm data is passed to the gamble action, and the action can access the data.

Figure 3.5Figure 3.5 A simple Page Flow in Action View.


Portals

Page Flows and controls, collectively known as Web applications, are the core content of a Web site. Portals are the mechanism through which content is put together and displayed to the user. As today's Web applications become increasingly more sophisticated, applications requiring -specialized sales campaigns, a customized look and feel, personalized services, and similar features are becoming more important.

WebLogic Platform 8.1 includes WebLogic Portal 8.1, which offers the following features:

  • Portals—Configurable desktop interfaces to application functionality. Portals enable you to define sophisticated look and feel, all packaged within a Portal Desktop.

  • Portlets—Individual pieces of functionality, based on HTML, Page Flows, Web services, and other areas, that can be reused with a Portal Desktop.

  • Books—Tabular definitions of collections of pages, used to group portlets into cohesive units.

  • Look and feel—A fully customizable engine for defining the look (styles, fonts, images, and so forth) and feel (rendering and behavior) of applications.

  • Custom content management—This feature includes services for logging in, defining user profiles, displaying profile-specific content, running specialized sales campaigns, and tailoring content based on individual user characteristics.

Figure 3.6 shows a simple portal application with a custom header. Chapters 12, "Overview of Portal Applications," and 13, "Personalization of Portal Applications," detail how to create Portal-enabled applications and take advantage of portal services.

Figure 3.6Figure 3.6 A simple portal application with a custom header.


Web Services and Business Process Integration

Many applications require integrated services. For all practical purposes, integration is the process of making various applications and systems work together seamlessly. Common integration tasks include

  • Creating business processes

  • Modeling complex, long-lived transactions

  • Converting data between formats

  • Implementing multiparty orchestrated messaging

  • Accessing data and logic in external systems

In support of integration, WebLogic Platform 8.1 includes WebLogic Integration (WLI) 8.1. WLI 8.1 includes a process management engine and tools for creating business processes, tools for administration, tools for creating and managing business processes that require human interaction (commonly referred to as worklists), an XQuery-based transformation engine, and various messaging services. Chapter 11, "Working with Workflows," goes into detail about how to use and build business process definitions.

WebLogic Workshop offers support for a full-featured Web services development environment, including accessing external Web services and creating new Web services. With WebLogic Workshop, you can create a control for accessing a remote service in minutes rather than hours. Figure 3.7 shows the Web Services Control Wizard dialog boxes for creating a Web service from the Web Services Description Language (WSDL) file published by a third party. All you need is access to the WSDL file, and Workshop can create controls to access both Remote Procedure Call (RPC) and document-style Web services. Chapter 9, "Working with Web Services," goes into depth about working with and building Web services and Web services controls.

Figure 3.7Figure 3.7 The Web Services Control Wizard dialog boxes.


Now you've seen a high-level view of a WebLogic Workshop application. In the following sections we'll look at it more closely.

  • + Share This
  • 🔖 Save To Your Account