Home > Articles

WebLogic Workshop Application Development Basics

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.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020