Previous Next vertical dots separating previous/next from contents/index/pdf

Step 3: Creating a Web Application and Testing it on a Server

In this step, you will create and run/deploy a complete (albeit very simple) web application.

The tasks in this step are:

Web applications that perform user interface functions (such as displaying "Hello, world!" in a browser page) are implemented as page flows. A page flow is a group of files (a Java controller class and JSP pages) that implement the flow of a portion of your user interface. When a user accesses a URL in the page flow, an instance of the controller class is created and remains in existence until the user exits the page flow. The page flow controller maintains state information for use by the controller's methods.

Web applications can contain several page flows that implement functional units. For example, one page flow could validate users, another page flow could browse data, and a third page flow might retrieve some specific information or perform navigation. Page flows in Workshop for WebLogic are based on the NetUI features of the open source framework called Beehive, a high-level project of Apache. Information on the organization and structure of NetUI and page flows is available in the NetUI Overview in the Apache Beehive documentation.

The page flow controller manages state variables and the actions of the page flow. When the initial (default) page flow controller is created, Workshop for WebLogic inserts a class definition that looks something like this:

public class Controller extends PageFlowController { }

@Jpf.Controller is an annotation which provides metadata for the page flow controller class. Annotations look like this:

@annotation-name ( parameters )

similar to method calls except that they begin with @. Annotations always occur immediately before the definition for the class or method to which the annotation applies--they annotate the class or method with metadata. As you modify the page flow, the annotation on the page flow class will be updated by Workshop for WebLogic.

Every page flow controller class must define the begin action, the entry point for the page flow. In the default class, the initial action for begin is defined by a parameter to the @Jpf.Controller annotation:

@Jpf.Controller(simpleActions = { @Jpf.SimpleAction(name = "begin", path = "index.jsp") })
public class Controller extends PageFlowController { }

The @Jpf.SimpleAction annotation specifies the begin action that opens the index.jsp page.

A page flow is implemented within a dynamic web project in Workshop for WebLogic. A dynamic web project can contain multiple page flows.

To Create a Dynamic Web Project

  1. Click File > New > Project.
  2. Expand Web, click on Dynamic Web Project, then click Next.
  3. In the New Dynamic Web Project dialog:
    1. Enter the name MyWebProject in the Project name field.
    2. Click on the Add Project to an EAR box and be sure that IntroTutorial_EAR is displayed in the EAR Project Name box.
    3. Click Finish.

After you create the dynamic web project, a top level folder is created for the project and the project files are initialized. The working file set includes a default page flow consisting of two files: in the src folder and index.jsp in the WebContent folder.

Depending on the options selected when creating the web projects, you may see a slightly different set of folders and files.

To Open the Initial (Default) Page Flow in the Web Project

To work with the default page flow controller:

  1. Open the file by double clicking on its name in the Project Explorer view. The file is located in
    MyWebProject/Java Resources/src/(default package). An editor will open displaying the file contents.
  2. Click Window > Open Perspective > Page Flow.
  3. The window changes to display the Page Flow perspective, a layout and set of views, menus, toolbars and editor pane most useful for creating page flows. There are several points to note:


To Edit the Page Flow Components

You can display/edit other source files (JSP pages or Java files) for your page flow by double clicking on their names in the Page Flow Explorer view at the left. When you open a file, Workshop for WebLogic creates an editor--a tab in the editor area where the file is open for editing.

Double clicking an action opens an editor for the page flow controller (if it is already open, its tab is brought to the top of the editor area) and positions the cursor at the method for that action.

To edit the index.jsp file:

  1. Expand Pages in the Page Flow Explorer view at the left.

  2. Double click on index.jsp. Another editor appears in the editor area. Change the default body text to Hello, world! and use the File > Save command to save the change.


To Run the Page Flow

The page flow is not very interesting at this point, since all that it does is invoke the initial JSP page index.jsp. However, to verify that the page flow works, let's run it now.

Workshop for WebLogic creates a WebLogic Server as part of installation and we will use this local server for testing the application we will create in this tutorial. You must set up the server before you can test any applications.

If you are working through this tutorial for a second time, you must remove previous, duplicate projects (modules) from the server.

The first time you run an application, Workshop for WebLogic prompts you for information about the test server. To run your application (and set up a WebLogic Server):

  1. On the editor for either index.jsp or, right click on the editor area and from the submenu, click Run As > Run on Server. From the Run on Server dialog, click Set server as project default so that when you run your projects in the future you will not be prompted again. Note that Manually define a new server is selected since you have not yet specified the server for testing.

    Click Next to proceed.

  2. The next dialog allows you to specify the domain to use for this server. Click on the pulldown and choose BEA_HOME\samples\domains\workshop to use the samples domain installed with Workshop for WebLogic. For this tutorial, it is sufficient to use the sample domain shipped with Workshop for WebLogic, so click Finish to proceed. You may also click the link Click here to launch Configuration Wizard to create a new domain to create a new domain.
  3. Now that you have specified the server for testing, it can take a few moments while Workshop for WebLogic creates and starts the server, deploys files to the server and runs the application. While the deployment is in process, you will see status messages displayed in the Servers view at the bottom of the window.

    The results appear in a new tab in the editor window. Note that the URL used to launch the application is .../Controller.jpf, where the JPF (Java Page Flow) was generated from the Controller.Java source file.



Click one of the following arrows to navigate through the tutorial:


Skip navigation bar   Back to Top