Home > Articles

This chapter is from the book

Creating Applications and Projects

As we introduced in Chapter 2, WebLogic Workshop creates J2EE enterprise applications containing one or more projects, libraries, modules, and security roles. Before Workshop, just laying out properties and configuring an application required a considerable amount of effort. However, Workshop makes creating new Web applications quick and easy. To create a basic Workshop application, select File, New, Application from the WebLogic Workshop menu. Figure 3.8 shows the New Application dialog box. In this figure, (A) indicates the types of applications displayed in the right pane; by default, all application types are shown. The application type list, labeled as (B), indicates the type of application being created. Default applications are basic Web applications and include XML Schema support. A default application contains a core, but minimal, application as a development starting point. Empty applications include Web application development support, but without a starting application. Portal applications are default applications that include additional portal support services, including a data project supporting rules, campaigns, and other portal features. Portal applications require a Portal-enabled server. Process applications are default applications that include integration and business process services and require an Integration-enabled server.

Figure 3.8Figure 3.8 The New Application dialog box.

The directory path, labeled (C), represents the root directory where the application will be created. The new application name, labeled (D), represents the name of the application as well as the topmost directory within the root directory. The Server text box, labeled (E), represents the target server for the application.

The Server text box is the most important field in the New Application dialog box. In the WebLogic Workshop programming world, applications and servers are tightly coupled. This tight coupling is a result of applications requiring specific services. Various servers provide different services and different feature sets. For example, an application might require WebLogic Portal or Integration support. Out of the box, WebLogic Workshop contains server definitions for the following:

  • Workshop—A Web application and Schema-enabled server supporting Web application development.

  • Portal—A WebLogic Portal–enabled server, supporting Web application and portal services and including all the services of the Workshop server.

  • Integration—A WebLogic Integration–enabled server, supporting Web application development using business processes and including all the services of the Workshop server.

  • End2end—A WebLogic Platform–enabled server containing all the services previously mentioned.

When building an application for the first time, you must choose a server that provides the required services. If you intend to create a Web application, select the Workshop server; otherwise, choose a server consistent with your development needs. Chapter 15, "Taking Your Applications from Development to Production," discusses the WebLogic Configuration Wizard. This wizard enables users to create domain definitions that can include any combination of the services required to support different application types.

On disk, Workshop applications are managed as expanded enterprise applications, but can be packaged into Enterprise Archives (EARs) easily by selecting Build, Build EAR from the main menu. The build process is examined further in "Building Applications," later in this chapter.

After creating a default Web application, WebLogic Workshop displays the Application pane (see Figure 3.9).

Figure 3.9Figure 3.9 A Workshop application with Schema and basic Web application support.

Starting WebLogic Server for Application Testing

Remember, you cannot test or debug applications without a running instance of WebLogic Server. Workshop has a number of menu shortcuts for starting, stopping, and running the WebLogic Server Console from the Workshop environment. To start an instance of WebLogic Server for an application, select Tools, WebLogic Server, Start WebLogic Server from the Workshop menu. To stop a running instance, select Tools, WebLogic Server, Stop WebLogic Server. To start the WebLogic Console, choose Tools, WebLogic Server, WebLogic Console. In addition, you can deploy, undeploy, or redeploy applications by using the Tools menu.

Workshop Applications Breakdown

Workshop Web applications are divided into three major sections. One major section is the Web application itself, named yournameWeb by default, which contains

  • -Controller.jpf—A default Page Flow used as the starting point of application development. Error.jsp and Index.jsp are two default pages used by the Page Flow.

  • resources—A folder containing a set of images, header and template JSP files, and associated stylesheets that can be used as the basis of a common look for a Web application. Note that template.jsp and header.jsp have a simplified look and feel and should not be confused with a portal look and feel.

  • WEB-INF—A folder containing all the XML-based application deployment descriptors, tag libraries, and XML definitions required to support Page Flows. Workshop manages almost all files in the WEB-INF folder, and these files should not be edited by hand.

Another major section is the default Schema project, which contains the following:

  • Schemas—A folder used to house any XML Schema files. Schemas can be added to this project by drag and drop. Newly added schemas are compiled, and then the generated XML Beans are added to the application's libraries folder. Application developers can use the generated XML Bean classes to create, delete, update, or otherwise manage associated XML.

The last major section is supporting libraries and security definitions common to the application folders:

  • Libraries—A folder containing all support libraries. You can add libraries to a project by dragging them into the Libraries folder, which maps to the APP-INF\lib directory of an enterprise application.

  • Modules—A folder containing all deployed J2EE enterprise resources. The Modules folder contains the application.xml and weblogic-application.xml files, which Workshop manages automatically. This folder maps to the META-INF folder of an enterprise application.

  • Security Roles—A folder containing application-defined security roles. The roles defined in an application are normally mapped to WebLogic Server groups. Security entries map to Security-role definitions in the application.xml file.

Workshop Projects

As we saw in Chapter 2, workshop applications contain one or more projects. These are the most common project types:

  • Web Application—These projects are standard Web applications packaged as Web Application Archive (WAR) files. Web Application projects contain a default Page Flow and support for creating new Page Flows, accessing existing controls, and creating new controls. Typically, Web projects are used to make Web applications available for use with browsers, but the application's functionality can also be made available via Web services.

  • Web Service—These projects are targeted at making application functionality available as a Web service using WSDL and are packaged into WAR files. Note that Web Service projects can contain Page Flows as well as Web services.

  • Control—Control projects consist solely of control classes, which are designed to be used by other developers to create portals, Web applications, and so forth. Control projects are packaged into Java archive (JAR) files and can be dropped into another application's lib directory.

  • EJB—EJB projects consist solely of EJBs and any support classes. EJB projects are packaged into JAR files and can also be used by being dropped directly into another application's lib directory.

  • Schema—Schema projects contain XML Schema files. Schema files are then compiled into XML Beans, a generated set of classes for managing XML documents. XML Beans are an exciting new BEA technology for creating, accessing, and working with XML. XML Beans are examined in detail in Chapter 10, "Handling Data in WebLogic Workshop: Working with Schemas and XML Beans."

  • Java Project—These projects contain packages of Java classes. Java projects are used to create reuseable class libraries and are packaged in JAR files.

In addition, if you have purchased or downloaded WebLogic Workshop Platform Edition, you can create other project types, such as

  • Process—Process projects consist of a default business process definition and compile into a JAR file that other projects or applications can access. Process projects can also be made available as Web services and accessed by other Web services platforms.

  • Portal and Datasync—Portal projects contain all the required infrastructure for creating portal applications. Creating a portal project results in the creation of a parallel datasync project containing rules, campaigns, placeholders, and other portal-specific features. Portal applications are packaged into EAR files.

To create a new project, select File, New, Project from the Workshop menu. Alternatively, select your application in the Application tab, right-click, and choose New Project. In the New Project dialog box (see Figure 3.10), select the type of project you would like to add. The type of project list, labeled (D) in Figure 3.10, displays subsets of the project types in the pane labeled (E). The All option displays all project types, and the other options display subsets of project types. Select the type, labeled (D), and the subtype, labeled (E), and enter your new project name in the space labeled (F). A new project is then added to Workshop, and corresponding entries are added in the underlying XML deployment descriptors.

Application Default Services

Applications are created supporting a default set of services. For example, Web applications do not support portal functionality by default. You can add portal or other project support to applications or projects by selecting the project, right-clicking, and choosing Install, support service from the menu. Support service could be WebLogic Portal or some other new service you want to use in your application. In this way, you can later add Portal or Integration support to a core Web application. Note that you might also need to select a new server because the core server might not include the runtime services required to support the new additions.

Figure 3.10Figure 3.10 The New Project dialog box.

With all the Workshop project types, the question is "When do you use one project type versus another?" When you need to build a portal project, the answer is clear. However, as a rule of thumb, you should use a different project whenever you are creating reuseable units of functionality or to separate unrelated functional areas. As we examine controls, portals, integration and other project and application types we will also examine when it is appropriate to create a new project or application, and when to extend the current application.

Installing Application Functionality

WebLogic Workshop is flexible in what kind of project to create. Web applications, portal projects, and process projects are the norm. However, what happens if you want a combination project, one that perhaps spans portals and workflows? One of the simplest ways to add functionality to a project is to select the root project, right-click, and choose Install. For example, you can insert portal support into a Web application by choosing Install, Portal.

Unfortunately, installing new support into an existing application is somewhat of a problem. Depending on the combination of resources, not everything works as planned, and it's never clear what the root cause is. So how can you create a project and be sure it will support the features you want? Practice has shown that the best way to develop an application is to start with the simplest project that supports the job at hand. In practice, that means creating controls (EJB, business process, or general) within their own projects, unit testing in an application that supports only those features you want, and then ultimately creating an overall application that supports all the features previously tested as standalone and integrates them together.

Use the following guidelines:

  • Create custom, rowset, and EJB controls in control projects. Unit test in Web applications.

  • Create business process controls in business process control projects. Delegate all background processing to custom controls. Place business logic only in business process controls.

  • Create portals and portlets in portal projects. Add only tested controls to portal projects.

  • Create overall applications that start with portal or business process support. Install other functionality to the application as required. Add tested logic via controls projects.

Accessing and Exposing Data via Controls

Applications, whether they are designed to support Web services or be accessed as Web or portal applications, require data as content and for decision logic. In Workshop applications, logic and data are provided by controls, which are the heart of any WebLogic Workshop application. Figure 3.2 introduced the Workshop controls model; Figure 3.11 shows a deeper view. Remember, workshop supports two different types of controls: resource or extensible controls (based on J2EE resources), resources, and custom controls written by developers. Custom controls are normally used to encapsulate data access or add business logic. To the developer, controls look much like standard Java objects; however, in addition to traditional methods, controls provide a number of other capabilities, such as

  • Asynchronous method invocation—The ability to call a long-running method and return immediately while the method continues in the background. (This is shown as a slashed arrow pointing into the control in Figure 3.11.)

Figure 3.11Figure 3.11 A deeper look at controls.

  • Callback method—The ability to invoke a method back to the calling client from a control. (This is shown as a slashed arrow pointing out of the control in Figure 3.11.)

  • Conversations—The ability to call methods that start, continue, and end a conversation.

  • Transaction support—Control methods are an implicit part of a transaction without any developer work.

One area that's becoming more important in messaging is connectivity. Three specific types of connected behavior can occur in today's networks: fully connected, in which the client and server are connected all the time; disconnected, in which the client is never connected to a server; and partially connected, in which the client is sometimes connected to the server and sometimes not. The control's runtime engine has support specifically targeted toward connectivity, namely the capability to manage a conversation. Controls can clearly define what methods start, continue, and end a conversation. More important, controls provide mechanisms for obtaining conversation IDs so that applications can disconnect and then later reestablish a conversation. The ability to reestablish a conversation is key to supporting a partially connected network model. Conversations, asynchronous methods, and callbacks are covered in detail in Chapters 7, "Using the NetUI Tag Library Toolbox to Develop Sophisticated JSPs," 9, "Working with Web Services," and 11, "Working with Workflows."

Adding Controls to Page Flows

The two most common uses of controls are to gather data for display and to make a logic decision. To use a control, you must add it to a Page Flow, open an action, and call methods on the control. Figure 3.12 shows two methods of adding a control to a Page Flow. If the control is part of the same application, it can be added by dragging the associated .jcx (Java extensible control) or .jcs (Java custom control) file into the right side of a Page Flow's Action View. Otherwise, you can right-click in the right side of a Page Flow Action View, select Controls, and then add the control. In either case, Workshop then prompts for the variable name of the new control and adds the control to your application. Listing 3.3 shows the code annotations added to a Controller when a control is added. Controls can then be accessed in actions like regular Java classes.

Figure 3.12Figure 3.12 Adding a control to a Page Flow.

Listing 3.3 Annotations Marking a Variable As a Control

public class Controller extends PageFlowController
  * @common:control
  private controls.Weather weather;

  * @common:control
  private db.games gamesDBCtrl;

Accessing Databases with Rowsets

One of the most common types of controls is the rowset control. The GamesDBCtrl shown in the previous example is a simple RowSet control enhanced to return value objects. Rowset controls are based on the java.sql.RowSet interface and provide a generic mechanism for accessing database data over a network. Rowsets are derived from the java.sql.ResultSet class and inherit much of the parent behavior. Rowsets can be used to add data, query for data, traverse rows of data, and delete data.

The RowSet Wizard generates several methods; the following two methods are used to read data:

  • RowSet getAllTbleName(DatabaseFilter)—This method return all rows for a given table and is filtered based on the database filter used as input to a where clause. Note that even if no filtering is required, you must provide a DatabaseFilter.

  • RowSet detailsTbleName(key)—This method returns the requested row based on the supplied key.

Rowset data is accessed by using one of the type-specific rowset methods, a generic example of which is shown here. All rowset accessor methods use the following form:

Type getType(String ColName);

In this form, type can be String, Int, Double, Float, Short, and so on. See the java.sql.RowSet documentation for a complete list.

Rowsets can return multiple rows of data. After a select clause, rowsets are initially positioned before the first row. You can iterate over a rowset by using the next() method.

The Wonderland Casino is actually made up of a number of casinos. Descriptive data about the casinos, games, hotels, and so on is stored in a database that could be accessed by using RowSet objects. The WONDERLAND.CASINOS table contains the complete list. Its SQL definition is shown here:


Assuming you have a RowSet object that contains all the casinos, you could traverse the list using the following:

While (allData.next())
  System.out.println("ID=" + allData.getInt("ID");
  System.out.println("Name=" + allData.getString("NAME");
  System.out.println("Desc=" + allData.getString("DESCR");

Wonderland Casino Sample Data

The Wonderland Casino database definition is in the {CDROM}:\db directory on this book's CD. You can add the Wonderland database to PointBase, the database tool packaged with WebLogic Workshop, by running the mkdb.cmd command script. First, you need to edit the set-dbenv.cmd script to point to your BEA install directory. To run the script, open a command prompt, and copy the scripts to a directory where they can be edited. Edit set-dbenv.cmd and then run mkdb.cmd. Additionally, if PointBase is running somewhere other than localhost:9093/ workshop, you need to update the pbcmd.cmd script appropriately.

The use of NetUI tags to present data is covered in detail in Chapter 7. However, you could easily display the entire list of RowSet data using a netui-data:repeater tag in a JSP. Assuming you returned a rowset of data from the Casinos table defined in a Page Flow as public RowSet casinos, you could access the data as a table using the code shown in Listing 3.4, with important lines shaded.

Listing 3.4 The netui-data:repeater Tag

<netui-data:repeater dataSource="{pageFlow.casinos}">
  <table border="1">
        <netui:label value="{container.item.ID}" />
        <netui:label value="{container.item.NAME}" />
        <netui:label value="{container.item.DESCR}" />

Adding and Deleting with Rowsets

In additional to reading data, rowsets support deleting, inserting, and updating data. The Casino Maintenance department has requested adding new functionality to the Wonderland Web site to support listing, adding, and deleting casinos. A new Page Flow, CasinoMaintenance, has been added to the Wonderland application. It supports listing, adding, and deleting casino table entries. To add an entry to a rowset, do the following:

  1. Obtain a template row by using detailsTBLNameTemplate().

  2. Update the row values.

  3. Insert the new row into the rowset.

  4. Insert the rowset contents into the database.

Listing 3.5 shows an example of these steps.

Listing 3.5 The doAdd Action of CasinoMaintenanceController.jsp

  protected Forward doAdd(AddForm form)
    String name = form.name;
    String description = form.description;
    try {
      RowSet newCasino = casinosdb.detailsCasinosTemplate();
      newCasino.insertRow(); // add the row into the rowset
      casinosdb.insertCasinos(newCasino); // add the row into the db
    } catch(SQLException sqle) {
      System.out.println("Unexpected SQLException on add:" +sqle);
    return new Forward("success");

Deleting a row from a database follows a similar pattern. To delete a row, follow these steps:

  1. Obtain a rowset containing the row based on the row's key.

  2. Set the rowset to the row you want to delete.

  3. Delete the row from the rowset.

  4. Delete the row from the database.

Listing 3.6 shows an example of these steps.

Listing 3.6 The doDelete action of CasinoMaintenanceController.jsp

  protected Forward doDelete(DeleteForm form)
    String id = form.ID;
    try {
      RowSet row = casinosdb.detailsCasinos(new Integer(id));
      row.absolute( 1 );
    } catch (SQLException sqle) {
      System.out.println("Unexpected SQLException on delete:" +sqle);
    return new Forward("success");

Creating Simple Rowset Controls

Rowset controls are the heart of any database application. There are, in fact, two types of database access controls. Database controls, which are similar to rowset controls, require all data access to be coded by hand. Rowset controls go a step further than database controls, in that they provide a core set of access methods, based on java.sql.RowSets, for accessing data. Developers are free to add functionality, but a set of core methods are supplied.

To create a rowset control, select a folder where the control will be created and follow these steps:

  1. Select File, New, Other File Types from the Workshop menu (see Figure 3.13).

  2. (Same as step A.)

  3. Select Business Logic in the left pane.

  4. Select RowSet Control in the right pane (see Figure 3.13), and click Create.

Figure 3.13Figure 3.13 Creating a rowset control.

  1. Enter the control variable name.

  2. Select an appropriate datasource.

  3. Select the methods to create, either Query and Update a Database Table (for traditional tables) or Query a View or Table (no update methods generated). The remainder of the steps for adding a rowset control are shown in Figure 3.14.

Figure 3.14Figure 3.14 Selecting methods, columns, and a primary key source in the RowSet Control Wizard.

  1. Select the schema and table name, and click Next.

  2. Select the columns to include, and click Next.

  3. Select the primary key mechanism, and click Create.

When you're finished, a new rowset control is created in the folder you selected. The new control can be used to access the table from a Page Flow or another control.

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.


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.


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.


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.


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


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


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.


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.


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