# Step 1: Begin the Page Flow Tutorial

In this step you will create the Investigate page flow. A page flow is a Java class (with the JPF file extension) that controls how your web application functions and what it does. Page flows control all of the major features of a web application: how users navigate from page to page, user requests, and access to the web application's back-end resources.

Page flows control the features of a web application through the use of Action methods. An Action method may do something simple, such as forward a user from one JSP page to another; or it may do something complex, such as receive user input from a JSP page, calculate and/or retrieve other data based on the user input, and forward the user to a JSP page where the results are displayed.

The page flow you create in this step contains one simple Action method. This simple navigational Action method forwards users to the index.jsp page. In the next step, you will create a more complex Action method.

The tasks in this step are:

- To start WebLogic Workshop
- To create a new application
- To start WebLogic Server
- To create a new page flow
- To test the page flow

To Start WebLogic Workshop

... on Microsoft Windows

If you are using a Windows operating system, follow these instructions.

1. From the Start menu, choose Programs-->WebLogic Platform 8.1-->QuickStart.
2. In the QuickStart dialog, click Experience WebLogic Workshop 8.1.

...on Linux

If you are using a Linux operating system, follow these instructions.

1. Open a file system browser or shell.
2. Locate the Workshop.sh file at the following address:

       $HOME/bea/weblogic81/workshop/Workshop.sh

3. In the command line, type the following command:

       sh Workshop.sh

Create a New Application

The application you create in this task contains resources for the page flow tutorial. The resources consist of the Invesitgate Java control (and its sub-components) and the Investigate web service. The Investigate Java control is a custom Java control that assembles a credit-worthiness report on loan applicants. The Investigate web service is a web service that gives web access to the Investigate Java control. For a detailed descriptions of these resources see Tutorial: Java Control and Tutorial: Web Service.

1. From the File menu, select New-->Application
2. In the New Application dialog, in the upper left-hand pane, select Tutorial.
   In the upper right-hand pane, select Tutorial: Page Flow.
   In the Directory field, use the Browse button to select a location to save your source files. (The folder you choose is up to you. The default location is shown in the illustration below.)
   In the Name field, type PageFlowTutorial.
   In the Server field, from the dropdown list, select BEA_HOME\weblogic81\samples\domains\workshop.
3. Click Create.

To Start WebLogic Server

As you develop the Investigate page flow, you will deploy it to WebLogic Server to test its functionality. In this task you will start WebLogic Server to ensure that it is available during the development process.

You can confirm whether WebLogic Server is running by looking at the status bar at the bottom of WebLogic Workshop. If WebLogic Server is running, a green ball is displayed as pictured below.

If WebLogic Server is not running, a red ball is displayed, as pictured below.

If you see the red ball in the status bar, then follow the instruction below to start WebLogic Server.

- To start WebLogic Server: from the Tools menu, choose WebLogic Server-->Start WebLogic Server.

To Create a New Page Flow

You will develop your page flow within a Web Application project. This project has been pre-loaded into WebLogic Workshop as part of the new application you created above.

1. On the Application tab, right click the PageFlowTutorialWeb folder and select New-->Page Flow.
2. In the Page Flow Wizard - Page Flow Name dialog, in the Page Flow Name field, enter investigateJPF, and click Next.
3. In the Page Flow Wizard - Select Page Flow Type dialog, confirm that Basic page flow is selected.
4. Click Create.

A new page flow, investigateJPFController.jpf, is created along with one JSP page, index.jsp. When you create a new page flow, it is automatically displayed in Flow View, a graphical representation of your page flow.

Flow View currently shows one Action method, named begin, and one JSP page, named index.jsp. The arrow, labeled "success", that points from the Action method to the JSP page tells you that the begin method is a navigational Action method: when the method is executed, it forwards users to the index.jsp page. (Not all Action methods are navigational: Action methods can do anything that a Java method can do.)

Every page flow must have a begin method. The begin method is the first method executed when your page flow is invoked by a web browser. When a user points a web browser at the page flow's URL

           http://localhost:7001/PageFlowTutorialWeb/investigateJPF/investigateJPFController.jpf

the begin method will be executed and the user will be forwarded to the index.jsp page.

To see the source code for the begin method, double-click the icon for the begin method.

The source code for the begin method is displayed in Source View.

Note that the begin method has two annotations within the Javadoc comment above the method signature: @jpf:action and @jpf:forward. Javadoc was originally introduced as a way to specify inline documentation that could be extracted and presented as HTML. WebLogic Workshop uses a variety of Javadoc annotations to indicate how code should be treated at compile time and at run time. The @jpf:action annotation declares that the method should be compiled as a Action method and that it should implement all of the functionality of an Action method. The @jpf:forward annotation declares that the method has navigational functionality. In this case, the @jpf:forward is able to forward users to the index.jsp page.

The begin method works as follows. (1) When the method is invoked, it returns a Forward object with the parameter "success". (2) The WebLogic Workshop runtime then searches for a @jpf:forward annotation that defines the destination corresponding to the parameter "success", in this case, the index.jsp page. When it finds the destination, it forwards the user to the index.jsp page.

To Test the Page Flow

1. Confirm that investigateJPFController.jpf is displayed in the main work area. (Throughout this tutorial, to display a file in the main work area, double-click its icon on the Application tab.)
2. Click the Start button, shown below.
   The page flow builds and the Workshop Test Browser launches. Notice the address bar of the Test Browser points to the page flow file investigateJPFController.jpf, but the browser displays the index.jsp page. When you point a browser at a page flow file, it executes its begin() method. In this case the begin() method forwards the user to the index.jsp page.

Click the arrow to navigate to the next step in the tutorial.