Introduction to Skyway Builder Tutorial

September 11, 2008

Abstract

This document is a step-by-step guide on how to develop a web application from scratch using Skyway Builder. This tutorial is the first tutorial in a series of tutorials that are available from the Skyway Community Portal.


Table of Contents

1. Introduction
1. What's Covered
2. Suggested Audience
3. Prerequisite Software
4. What are we going to build?
4.1. User Story
5. Support
6. Skyway Development Artifacts
7. Application Layers
8. Implementation Overview
9. Development Process
9.1. Development Steps
2. Skyway Project
1. TASK: Create Skyway Project for PAM
1.1. TASK: Define Project Variables
3. Data Layer
1. Model
1.1. TASK: Add AppraisalService to Project
1.2. TASK: Add Appraisal Data Type
2. Persistence
2.1. TASK: Add AppraisalDS Data Store
4. Service Layer
1. Model
1.1. TASK: Add SaveAppraisal Operation
1.2. TASK: Define Operation Input and Output Variables
1.3. TASK: Create Save Action
5. Web Layer
1. Web View Mappings
1.1. TASK: Create index.jsp Page
1.2. TASK: Create edit.jsp Page
1.3. TASK: Create confirm.jsp Page
1.4. TASK: Define page aliases
2. Controller
2.1. TASK: Add PAMController Web Controller
2.2. TASK: Add the PerformanceMgmt Web Conversation
2.3. TASK: Define Web Conversation Variables
2.4. TASK: Add the InitConversation Action
2.5. TASK: Add the InitNewAppraisal Action
2.6. TASK: Add the ValidateAppraisal Action
2.7. TASK: Add the SaveAppraisal Action
3. View - JSP Pages
3.1. TASK: Implement index.jsp Page
3.2. TASK: Implement edit.jsp Page
3.3. TASK: Implement confirm.jsp Page
3.4. TASK: Configure URL Action Mappings
6. Deployment
1. Configure Database
1.1. Add Data Source
1.2. Configure Data Store in Project
2. Configure Server
2.1. Add Server
2.2. Add PAM Project to Server
3. Run Application
3.1. Start Server
3.2. Run Application

List of Figures

1.1. Project Meta-Data Model
1.2. End-User View of Application
1.3. Developer View of Application
2.1. New --> Project
2.2. Wizard: Create a Skyway Project - Skyway Project
2.3. Wizard: Create a Skyway Project - Folder Names
2.4. Editor: Project Editor - Variables
3.1. New --> Service
3.2. Wizard: New Skyway Service
3.3. New --> Data Type
3.4. Wizard: New Data Type
3.5. Editor: Data Type Editor - Overview
3.6. Data Type: Appraisal Fields
3.7. Wizard: New Data Store
3.8. Wizard: New Data Store - Add Data Types
3.9. Wizard: New Data Store - Managed Data Types
3.10. Editor: Data Store Editor - Overview
3.11. Editor: Data Store Editor - Database Configuration
4.1. Wizard: New Operation - Name
4.2. Wizard: New Operation - Entry Point Action
4.3. Editor: Operation Editor - Overview
4.4. Select Type
4.5. Editor: Operation Editor - Inputs/Outputs
4.6. Open Action Editor
4.7. Step Palette
4.8. Operation Action: Save
4.9. Properties: Modify Data Store Step - Modify
5.1. Wizard: New JavaServer Page - Name
5.2. Wizard: New JavaServer Page - Template
5.3. View Mappings
5.4. Wizard: New Web Controller
5.5. Developer View of Application - Web Conversation
5.6. Wizard: New Web Conversation
5.7. Editor: Web Conversation Editor
5.8. Editor: Web Conversation Editor - Variables
5.9. Developer View of Application - InitConversation
5.10. Wizard: New Action - Name
5.11. Wizard: New Action - URL Action Mapping
5.12. Conversation Action: InitConversation
5.13. Properties: Search Data Store - Select Data Store Info
5.14. Properties: Search Data Store - Search Criteria
5.15. Developer View of Application - InitNewAppraisal
5.16. Conversation Action: InitNewAppraisal
5.17. Developer View of Application - ValidateAppraisal
5.18. Conversation Action: ValidateAppraisal
5.19. Properties: Decision Step - Decision Criteria
5.20. Properties: Variable Editor - Variable Editor
5.21. Properties: Variable Editor - Variable Editor
5.22. Developer View of Application - SaveAppraisal
5.23. Conversation Action: SaveAppraisal
5.24. index.jsp - runtime view
5.25. index.jsp - full listing
5.26. edit.jsp - runtime view
5.27. edit.jsp - full listing
5.28. confirm.jsp - runtime view
5.29. confirm.jsp - full listing
5.30. URL Action Mapping
5.31. URL Action Mapping

List of Tables

2.1. Project Wizard Configuration
2.2. Project Variables: PAM
3.1. Data Type: Appraisal Fields
4.1. Operation Wizard Configuration: SaveAppraisal
4.2. Operation Inputs: SaveAppraisal
4.3. Action Implementation: Save Action
5.1. Conversation Variables: PerformanceMgmt
5.2. Action Implementation: InitConversation Action
5.3. Action Implementation: InitNewAppraisal Action
5.4. Action Implementation: ValidateAppraisal Action
5.5. Action Implementation: SaveAppraisal Action
5.6. Action Implementation: ValidateAppraisal Action

Chapter 1. Introduction

Welcome to the Introduction to Skyway Builder tutorial. This document is a step-by-step guide on how to develop a web application from scratch using Skyway Builder. This tutorial is the first tutorial in a series of tutorials.

1. What's Covered

This tutorial will introduce new users to application development using Skyway Builder through the development and deployment of a simple web application.

2. Suggested Audience

This tutorial is intended for developers with familiarity with Java-based web development and Eclipse. It is assumed that the developer has basic experience with running a JEE Application Server and a database management system.

3. Prerequisite Software

The prerequisites completing this tutorial are

  • Skyway Builder 6.0 Community Edition or Skyway 6.0 Enterprise Edition

  • Java Application Server: Apache Tomcat 6.0

  • Database Management System (DBMS): Postgres 8.1 -or- MySQL 5.1 Database

The setup of the application server and database management system is beyond the scope of this tutorial. If you need assistance setting up a sandbox which includes Tomcat and MySQL, please see refer to the Skyway Builder Sandbox Setup guide or Video Tutorial that can found in the Resources section of the Skyway Community Portal.

4. What are we going to build?

The goal of this tutorial is to provide a step-by-step example of building a web application using Skyway Builder. Skyway Builder CE is a subset of the development functionality, and this tutorial isn't making use of any of the additional Skyway Builder EE features. So this tutorial is applicable to all versions of Skyway Builder (CE and EE). While it is intentionally limited in scope, it introduces new users to application development using Skyway Builder.

The web application that will be implemented is a tool for managing the performance reviews of team members, and the application is called Performance Appraisal Management (PAM).

4.1. User Story

Here's a description of the requirements of PAM using user stories:

User Stories

  • Reviewer can list all performance appraisals.

  • Reviewer can add a performance appraisal.

  • An appraisal has employee first name, last name, and employee number.

  • An appraisal covers three topics: design, programming, testing.

  • A optional comment can be included for each appraisal.

  • There are three appraisal ratings: 3-does not meet expectations, 2-meets expectations, 1-exceeds expectations.

5. Support

If you need help, there is a forum on the Skyway Community portal dedicated to the Skyway Tutorials.

6. Skyway Development Artifacts

Application development using Skyway Builder is accomplished by using (assembling and configuring) graphical development artifacts:

Figure 1.1. Project Meta-Data Model

Project Meta-Data Model

 

Summary of Skyway Development Artifacts

  • Projects are the top level artifact within the developer's workspace. All other objects must be made within projects but can access objects within and across project boundaries.

  • Data Types are used to define the domain model. Developers can specify standard primitive types for the fields within a Data Type and can also specify relationships to other Data Types and their cardinality.

  • Data Stores are abstract representations of real databases that are used in the modelling environment when persistence is needed. During deployment Data Stores are bound to a real, physical implementation of a database.

  • Services are used to implement the Service layer of an application.

  • Operations are discrete application functions defined in a Service.

  • Actions are the model-based implementation of application. Actions are created by sequencing Steps together.

  • Web Controllers are used to implement the Web layer of an application, and they have one or more Conversations.

  • Web Conversations are task-based groupings of logic for handling user event. Conversations are implemented using Actions.

  • Views are Java Server Pages (JSP) that implement the Presentation layer.

  • Exceptions are definitions of certain types of errors that the developer may want to surface as the models become code and are executed.

7. Application Layers

This application will implemented in three layers:

The web layer (also referred to as the UI layer) is primarily concerned with presenting the user interface and handling user interactions/events. The Skyway artifacts for implementing the web layer are the Web Controller, Web Conversation, Action, Steps and JSP pages.

The service layer (also referred to as the logic layer or business layer) represents the core functionality of the application being built. The Skyway artifacts for implementing the service layer are the Service, Operation, Action, and Steps.

The data layer (also referred to as the persistence layer or domain object layer) is represented by a domain model; a distinct set of inter-related application objects that embody the functionality and characteristics of the system being built. This layer also encompasses the persistence of the domain model to and from a database. The Skyway artifacts for implementing the data layer are the Data Type and Data Store artifacts.

8. Implementation Overview

Figure 1.2. End-User View of Application

End-User View of Application

End-User View of Application

  • Step 1: End-user goes to index.jsp, the starting page of the application. From here the user will see a list of performance appraisals in the database. There is also a "New Appraisal" hyperlink that the user can click on to start the new appraisal process.

  • Step 2: Clicking on the "New Appraisal" hyperlink loads edit.jsp, the appraisal entry form. The end-user enters all the data, and clicks the "Next" button.

  • Step 3: After clicking on the "Next" button, then appraisal will be validated on the server. If the appraisal passes validation, the confirm.jsp page will load. If the appraisal doesn't pass validation, the edit.jsp will be reloaded.

  • Step 4: From the confirm.jsp page, the end-user will confirm that the appraisal should be submitted to PAM system.

  • Step 5: Upon a successfull save, the user will be returned to the index.jsp page.

Figure 1.3. Developer View of Application

Developer View of Application

Developer View of Application using Skyway Builder

  • Step 1: Prior to the page rendering, there is some data loading and variable housecleaning (clearing data) that needs to occur. This is implemented in the InitConversation action. The URL Action Mapping (UAM) is configured to fire the InitConversation action prior to the /home page (index.jsp) page being rendered.

  • Step 2: The "New Appraisal" hyperlink on the index.jsp page is configured with a URL that is mapped by the UAM to call the InitNewAppraisal action. This action will initialize variables, and upon completion the UAM will defer to the /edit page (edit.jsp) to render the view (or response).

  • Step 3: The end-user will press the "Next" button when finished filling in the appraisal form. The "Next" button is configured with a URL that is mapped by the UAM to call the ValidateAppraisal action. This action will verify that all the required appraisal details were specified by the end-user. This action can go to one of two pages based on the result of the validation logic. This is accomplished with a project variable that the UAM uses to determine the view. If the appraisal passes validation, the action will set the project variable to /confirm page (confirm.jsp). If the appraisal doesn't pass validation, the action will set the project variable to the /edit page (edit.jsp).

  • Step 4: The "Confirm" button on the confirm.jsp page is configured with a URL that is mapped by the UAM to call the SaveAppraisal action. This action will call the SaveAppraisal operation (which will persist the appraisal).

  • Step 5: Upon completion the UAM will reload the /home page (index.jsp).

Use the following Skyway Navigator screenshot as a guideline for implementing the project

9. Development Process

9.1. Development Steps

Application development with Skyway Builder generally consists of five steps, and the tutorial is structured according to these steps.

 

High-level Development Steps Defined

Please refer to the Skyway Builder Developer Guide for a more detailed explanation of these development steps.

Chapter 2. Skyway Project

This chapter will outline the steps for creating the PAM project.

1. TASK: Create Skyway Project for PAM

Projects are the top level development artifact within Skyway Builder. All other Skyway artifacts must reside inside a project. In many cases (as is the case with PAM) a web application is implemented as a single project, with the project containing any and all artifacts needed to provide its functionality. Since a project can reference development artifacts in other projects, there are cases where an application consists of multiple projects.

Steps:

  1. Right click in Skyway Navigator, and select New-->Project

  2. From the New Project Wizard, pick "Skyway Project" from the "Skyway" folder. This will open the Create Skyway Project Wizard, which is used to specify name, location and sub-folders to be used for the project.

    Figure 2.1. New --> Project

    New --> Project

  3. Configure the Create Skyway Project Wizard as follows:

    Table 2.1. Project Wizard Configuration

    PanelFieldValue
    Skyway ProjectProject Name:PAM
    Skyway ProjectUse default location:yes (default)
    Folder NamesFolder to create for web content:WebContents (default)
    Folder NamesFolder to create for models:models (default)

    Figure 2.2. Wizard: Create a Skyway Project - Skyway Project

    Wizard: Create a Skyway Project - Skyway Project

    Figure 2.3. Wizard: Create a Skyway Project - Folder Names

    Wizard: Create a Skyway Project - Folder Names

  4. When done, click Finish.

You now have a Skyway project that you can version control using Eclipse, just like any other Eclipse project.

1.1. TASK: Define Project Variables

Project variables are variables that are available to any and all project artifacts. Project variables are session scoped, so they exist for the life of the user session.

For the PAM project we will define one variable (page) for dynamic page navigation. In certain parts of the implementation we will use this variable to control page flow.

Steps:

  1. Open the Project Editor by double-clicking on the PAM project icon. Switch to the Variables tab, which is located along the bottom of the editor, and add variables per the following table. As you add variables, the type picker will show you the Skyway Basic types plus any data types defined in any open Skyway projects.

    Table 2.2. Project Variables: PAM

    NameTypeCollectionInitial Value
    pageTextNo 

    Figure 2.4. Editor: Project Editor - Variables

    Editor: Project Editor - Variables

  2. Save the project using File-->Save.

Chapter 3. Data Layer

The data layer (also referred to as the persistence layer or domain object layer) is represented by a domain model; a distinct set of inter-related application objects that embody the functionality and characteristics of the system being built. This layer also encompasses the persistence of the domain model to and from a database. The Skyway artifacts for implementing the data layer are the Data Type and Data Store artifacts.

This chapter will outline the steps for implementing the data layer for PAM.

1. Model

1.1. TASK: Add AppraisalService to Project

A Skyway Service is a container for data and logic artifacts. This task entails creating data artifacts. Defining logic will done in a later task

Steps:

  1. Right click on PAM project, and select New-->Service

    Figure 3.1. New --> Service

    New --> Service

  2. From the New Skyway Service Wizard, enter "AppraisalService" for the filename. This will be the name of the new service. The container for this service should be the project (PAM). If the project is not highlighted, then select the project.

    Figure 3.2. Wizard: New Skyway Service

    Wizard: New Skyway Service

  3. When done, click Finish.

1.2. TASK: Add Appraisal Data Type

Data Types are used to define domain objects that will be utilized within an application. You can add object attributes by using the basic data types, and you can also specify relationships to other Data Types and their cardinality.

Steps:

  1. Righ click on the AppraisalService service, and select New-->Data Type

    Figure 3.3. New --> Data Type

    New --> Data Type

  2. From the New Data Type Wizard, enter "Appraisal" for the filename. This will be the name of the new data type. The container for this data type should be the service (AppraisalService). If the service not highlighted, then select the service.

    Figure 3.4. Wizard: New Data Type

    Wizard: New Data Type

  3. When done, click Finish. This will open the Data Type editor.

    Figure 3.5. Editor: Data Type Editor - Overview

    Editor: Data Type Editor - Overview

  4. From the Overview tab of the Data Type editor, add the following fields.

    Table 3.1. Data Type: Appraisal Fields

    Display NameTypePrimary Key
    employeeNoTextYes
    lastNameText 
    firstNameText 
    ratingDesignInteger 
    ratingProgrammingInteger 
    ratingTestingInteger 
    commentsLargeText 

    Figure 3.6. Data Type: Appraisal Fields

    Data Type: Appraisal Fields

  5. Save the data type using File-->Save. You may also close the editor.

2. Persistence

2.1. TASK: Add AppraisalDS Data Store

Data Stores are abstract representations of real databases (or persistence mechanisms), and they manage persistence for a set of data types. When designing the models there is no need to know the detail of the database (vendor, version, IP, etc.), but simply a need to know that one exists for modeling database activity. When models are deployed, the developer late binds each Data Store to a real, physical implementation of a database.

Steps:

  1. Right click on the AppraisalService service, and select New-->Data Store

  2. From the New Data Store Wizard, enter "AppraisalDS" for the filename. This will be the name of the new data store. The container for this data type should be the service (AppraisalService). If the service not highlighted, then click on it before clicking Next to go to the next panel.

    Figure 3.7. Wizard: New Data Store

    Wizard: New Data Store

  3. From the Add Data Type panel, click the Add button, and select the "Appraisal" data type from the Data Types list.

    Figure 3.8. Wizard: New Data Store - Add Data Types

    Wizard: New Data Store - Add Data Types

    Figure 3.9. Wizard: New Data Store - Managed Data Types

    Wizard: New Data Store - Managed Data Types

  4. When done, click Finish. This will open the Data Store editor.

    Figure 3.10. Editor: Data Store Editor - Overview

    Editor: Data Store Editor - Overview

  5. On the Database Configuration tab the database connection should be defaulted to the data connection you created when you performed the Sandbox setup prerequisites. Per the sandbox setup guide, the db connection is called SkywayDB. If you haven't created a connection yet, you can create a new connection from here.

    Figure 3.11. Editor: Data Store Editor - Database Configuration

    Editor: Data Store Editor - Database Configuration

  6. Save the data store using File-->Save.

Chapter 4. Service Layer

The service layer (also referred to as the logic layer or business layer) represents the core functionality of the application being built. The Skyway artifacts for implementing the service layer are the Service, Operation, Action, and Steps.

This chapter will outline the steps for implementing the service layer of PAM.

For the PAM project there is only one operation in the service layer. The SaveAppraisal operation is intended to handle all persistence logic associated with saving an appraisal. For the tutorial the logic is very basic; the appraisal will simply be persisted to a database. However as the application requirements change in the future, you can add additional functionality (i.e. checking for duplicate entries, sending email notifications, updating HR system).

1. Model

1.1. TASK: Add SaveAppraisal Operation

Service functions are specified as Operations, which represent stateless application logic. In addition to a name and description, the operation definition consists of an operation interface and operation resources. The actual application logic of an operation is implemented using Actions (which will be covered in a later task).

In the case of PAM, the approval logic is implemented as a Service. It could have been implemented in the web layer, but it would have (a) limited the reusability of the logic, and (b) not given you a chance to implement a Service.

Steps:

  1. Right click on the AppraisalService service, and select New-->Operation

  2. Configure the Create Skyway Project Wizard as follows:

    Table 4.1. Operation Wizard Configuration: SaveAppraisal

    PanelFieldValue
    New Skyway OperationFile Name:SaveAppraisal
    Entry Point ActionCreate an entry point action:yes (default)
    Entry Point ActionAction Name:Save

    Figure 4.1. Wizard: New Operation - Name

    Wizard: New Operation - Name

    Figure 4.2. Wizard: New Operation - Entry Point Action

    Wizard: New Operation - Entry Point Action

  3. When done, click Finish. This will open the Operation editor.

    Figure 4.3. Editor: Operation Editor - Overview

    Editor: Operation Editor - Overview

The operation name will be used when referencing this operation from elsewhere in the application.

Depending on the amount of functionality in an operation, an operation can be implemented with one or more actions. In the event there's multiple actions, one of the actions must be defined as the entry point. When you initially create an operation, you can have the initial action automatically created for you, and you can also have the action preconfigured as the entry point.

1.2. TASK: Define Operation Input and Output Variables

Inputs and Output variables partly define the operation contract. When another application artifact wants to call an operation, it must pass in the input variables and accept the output variables.

In the case of the SaveAppraisal action, the input will be an appraisal object, and there are no outputs.

Steps:

  1. From the Inputs/Outputs tab of the Operation Editor, add an input variable per the following table. Adding variables is very similar to adding variables to a project. As you add variables, the type picker will show you the Skyway Basic types plus the data types of any open Skyway projects.

    Figure 4.4. Select Type

    Select Type

    Table 4.2. Operation Inputs: SaveAppraisal

    NameTypeCollection
    inAppraisalAppraisalNo

    Figure 4.5. Editor: Operation Editor - Inputs/Outputs

    Editor: Operation Editor - Inputs/Outputs

  2. Save the operation using File-->Save.

1.3. TASK: Create Save Action

While the operation defines the interface and resources needed for an application function, the functionality is actually implemented using Actions. The developer defines the logic to be performed by sequencing steps together.

Adding actions to the an operation is normally accomplished by right-clicking on the Operation, and selecting "New-->Action". However during the creation of the operation, we were given the option to have an action automatically created and preconfigured as the entry point. If you expand the SaveAppraisal operation, you will see the "Save" action.

Steps:

  1. Open the Save action by double-clicking on the action in the Skyway Navigator. This will open the Action editor.

    Figure 4.6. Open Action Editor

    Open Action Editor

  2. From here you will model the implementation of the operation. In this case the operation will be implemented with one step, so it can be modeled using only the entry-point action. However in other cases, as described earlier, you may choose to decompose the logic into multiple actions that are strung together by the entry-point action.

    To implement the Action, open the step palette.

    Figure 4.7. Step Palette

    Step Palette

  3. Implementing the Action consists of dropping the desired steps onto the canvas, configuring the steps (properties), and stringing the steps together into a flow. Click on the Modify Data Store step and then click on the canvas. Repeat this for all the steps listed in the following table.

  4. Once the steps are added the canvas, you can configure the steps by double-clicking on the step to open the step properties. Configure the step properties using the following table as a reference.

    Table 4.3. Action Implementation: Save Action

    Step NameStep TypeConfiguration
    Persist Appraisal
    Modify Data Store
    Properties-->Modify Tab
    • Data Store: AppraisalDS

    • Operation: Update

    • Operation Input: inAppraisal

    Stop
    Stop
     NoteOptional Text: "This action persists the appraisal to the data source."

  5. To connect the steps, click on the Connector in the palette, click on the first step (Persist Appraisal) and drag to the second step (Stop).

  6. Save the action using File-->Save.

    Figure 4.8. Operation Action: Save

    Operation Action: Save

    Figure 4.9. Properties: Modify Data Store Step - Modify

    Properties: Modify Data Store Step - Modify

Chapter 5. Web Layer

The web layer (also referred to as the UI layer) is primarily concerned with presenting the user interface and implementing the behavior of the application. The Skyway artifacts for implementing the web layer are the Web Controller, Web Conversation, Action, Steps, and JSP pages.

This chapter will outline the steps for implementing the web layer of PAM.

1. Web View Mappings

The web layer of the PAM application is implemented using a variety of different Skyway artifacts, and the user interface is implemented using JSP pages. During the flow of the application, control will be passed back-and-forth between Actions and JSP pages. As an action performs it's function, a corresponding JSP page will render the response. Rather than hard-coding references to specific JSP pages from the Actions, which is generally regarded a bad practice, a common solution is to define and use aliases to JSP pages. View mappings are the mechanism for defining and associating aliases to JSP pages. When an Action needs to reference a JSP page, it references an alias to the page instead of the actual JSP page.

Before we can define the aliases, we must first create the JSP pages. The JSP pages won't actually be implemented until the next chapter.

1.1. TASK: Create index.jsp Page

Steps for creating index.jsp:

  1. Right click on WebContent folder, and select New-->JSP. This will open the New JavaServer Page Wizard.

  2. Enter index.jsp as the filename, and click the Next button.

    Figure 5.1. Wizard: New JavaServer Page - Name

    Wizard: New JavaServer Page - Name

  3. Select Skyway JSP File (html) as the template, and click the Finish button.

    Figure 5.2. Wizard: New JavaServer Page - Template

    Wizard: New JavaServer Page - Template

1.2. TASK: Create edit.jsp Page

Steps for creating edit.jsp:

  1. Create another JSP page called edit.jsp using Skyway JSP File (html) as the template.

1.3. TASK: Create confirm.jsp Page

Steps for creating confirm.jsp:

  1. Create another JSP page called confirm.jsp using Skyway JSP File (html) as the template.

1.4. TASK: Define page aliases

To create a View Mapping, double click the PAM project to bring up it’s properties. Then select the View Mappings tab on the bottom.

The following figure shows how the view mappings are configured to associate an alias with an actual JSP page. Start by adding (Add...) each JSP page as a View Resource and specify the alias to be associated with the JSP page.

Figure 5.3. View Mappings

View Mappings

2. Controller

2.1. TASK: Add PAMController Web Controller

As described earlier Web Controllers are used along with the JSP pages (located in the WebContent) to implement the Web layer of an application. The JSP pages represent the View in MVC, and Web Controllers represent the Controller in MVC. Per the project meta-data model, a Web Controller can have one or more Web Conversations, which will be described in a subsequent task.

Steps:

  1. Right click on PAM project, and select New-->Web Controller

  2. From the New Web Controller Wizard, enter "PAMController" for the filename. This will be the name of the new web controller. The container for this web controller should be the project (PAM). If the project is not highlighted, then select the project.

    Figure 5.4. Wizard: New Web Controller

    Wizard: New Web Controller

  3. When done, click Finish.

2.2. TASK: Add the PerformanceMgmt Web Conversation

A Web Conversation facilitates the grouping of processing logic around application tasks, which is typically comprised of a series of steps between the end-user and the application. Therefore each application task is implemented as it's own conversation, and each conversation contains the variables, constants, and Actions needed to orchestrate the task and support the user events associated with the task. These types of Web Conversations will typically be session scoped. When the task is done, the conversation state can be discarded using the Clear Conversations step.

Figure 5.5. Developer View of Application - Web Conversation

Developer View of Application - Web Conversation

Steps:

  1. Right click the on PAMController web controller, and select New-->Web Conversation

  2. From the New Web Conversation Wizard, enter "PerformanceMgmt" for the filename. This will be the name of the new web conversation. The container for this web conversation should be the web controller (PAMController). If the web controller is not highlighted, then select the web controller.

    Figure 5.6. Wizard: New Web Conversation

    Wizard: New Web Conversation

  3. When done, click Finish. This will open the Web Conversation editor.

    Figure 5.7. Editor: Web Conversation Editor

    Editor: Web Conversation Editor

2.3. TASK: Define Web Conversation Variables

Web Conversation variables are the variables used by Actions. All actions in a Web Conversation share the same variables. This reinforces the concept of a conversation being oriented around an application task or function where different steps in the task will need to share variables and state. In the case of PAM there will be two variables. One variable (appraisals) is for holding all appraisals for the purpose of listing on the front page, and another variable (currentAppraisal) is for storing the appraisal details entered by the end user.

Steps:

  1. From the Variables tab of the Web Conversation Editor, add variables per the following table. As you add variables, the type picker will show you the Skyway Basic types plus any data types in Skyway projects.

    Table 5.1. Conversation Variables: PerformanceMgmt

    NameTypeCollectionPublic
    currentAppraisalAppraisalNoYes
    appraisalsAppraisalYesYes

    Figure 5.8. Editor: Web Conversation Editor - Variables

    Editor: Web Conversation Editor - Variables

  2. Save the conversation using File-->Save.

2.4. TASK: Add the InitConversation Action

Actions in the context of a web conversation (as opposed to a service operation) implement the logic for handling user-generated events. The developer defines the logic to be performed by the action by sequencing steps together.

Figure 5.9. Developer View of Application - InitConversation

Developer View of Application - InitConversation

The first action, InitConversation, is intended to do some housecleaning. Since the end-user dictates the flow of the application, the state of the application cannot be assumed. Therefore this action is intended to assure that the application is in a predetermined state. Prior to loading the index page and listing all current appraisals, the appraisals should be loaded into the appraisals variable.

When this action is created, a partially configured URL Action Mapping will also be created. In a later section we will complete the configuration of the URL Action Mapping to fire prior to displaying the index page.

Steps:

  1. Right click the on PerformanceMgmt web conversation, and select New-->Action

  2. From the New Action Wizard, enter "InitConversation" for the filename. This will be the name of the new action. The container for this action should be the web conversation(PerformanceMgmt). If the web conversation is not highlighted, then select the web conversation.

    Figure 5.10. Wizard: New Action - Name

    Wizard: New Action - Name

    Figure 5.11. Wizard: New Action - URL Action Mapping

    Wizard: New Action - URL Action Mapping

  3. When done, click Finish. This will open the Action editor.

  4. From here you will model the implementation of the action. Implementing the Action consists of dropping steps onto the canvas, configuring the steps, and stringing the steps together into a flow. The following diagram shows the implementation of the InitConversation action.

    Figure 5.12. Conversation Action: InitConversation

    Conversation Action: InitConversation

  5. In this case there are only two steps. Once a step is added the canvas, you can configure the step by double-clicking on the step to open the step properties.

    Table 5.2. Action Implementation: InitConversation Action

    Step NameStep TypeConfiguration
    Retrieve All Appraisal
    Search Data Store

    Properties-->Select Data Store Info

    • Search Data Store: PAM.AppraisalService.AppraisalDS

    • Target Variable: ${appraisals}

    Properties-->Search Criteria

    • Criteria Type: All Records

    Properties-->Sort Fields

    • None

    Stop
    Stop
     NoteOptional Text: "This action persists the appraisal to the data source."

    Figure 5.13. Properties: Search Data Store - Select Data Store Info

    Properties: Search Data Store - Select Data Store Info

    Figure 5.14. Properties: Search Data Store - Search Criteria

    Properties: Search Data Store - Search Criteria

  6. A Note can be optionally added to an action to describe the functionality of the action.

2.5. TASK: Add the InitNewAppraisal Action

Figure 5.15. Developer View of Application - InitNewAppraisal

Developer View of Application - InitNewAppraisal

The InitNewAppraisal action is intended to prepare the conversation for creating a new appraisal. When the "New" hyperlink is clicked by the end-user, the InitNewAppraisal action will be invoked, which will create a new appraisal object to make sure that any data that may have been previously entered by the end-user is discarded.

Steps:

  1. Right click the on PerformanceMgmt web conversation, and select New-->Action

  2. From the New Action Wizard, enter "InitNewAppraisal" for the filename. This will be the name of the new action. The container for this action should be the web conversation(PerformanceMgmt). If the web conversation is not highlighted, then select the web conversation.

  3. When done, click Finish. This will open the Action editor.

  4. From here you will model the implementation of the action. Implementing the Action consists of dropping steps onto the canvas, configuring the steps, and stringing the steps together into a flow. The following diagram shows the implementation of the InitConversation action.

  5. In this case there are only two steps. Once a step is added the canvas, you can configure the step by double-clicking on the step to open the step properties.

    Table 5.3. Action Implementation: InitNewAppraisal Action

    Step NameStep TypeConfiguration
    New Appraisal
    Variable Editor
    Properties-->Variable Editor
    • Variable:currentAppraisal = RESET

    Insert the currentAppraisal variable using the Insert Variable button, and then press the Reset button. The Reset button will append the "= RESET" to the expression.

    Stop
    Stop
     NoteOptional Text: "This action persists the appraisal to the data source."

    Figure 5.16. Conversation Action: InitNewAppraisal

    Conversation Action: InitNewAppraisal

  6. A Note can be optionally added to an action to describe the functionality of the action.

2.6. TASK: Add the ValidateAppraisal Action

Figure 5.17. Developer View of Application - ValidateAppraisal

Developer View of Application - ValidateAppraisal

The ValidateAppraisal action is responsible for validating the appraisal data that was entered by the end-user. In this implementation the validation logic is very basic. The only thing that is being verified is that an employeeNo is specified. Based on the evaluation of the appraisal object, this action will direct the end-user either to the /confirm page (alias) or back to the /edit page (alias). In contrast with the other actions in the PerformanceMgmt conversation which go to one and only one page, the next page will be determined by the page project variable which will be set with a page alias.

Steps:

  1. Right click the on PerformanceMgmt web conversation, and select New-->Action

  2. From the New Action Wizard, enter "ValidateAppraisal" for the filename. This will be the name of the new action. The container for this action should be the web conversation (PerformanceMgmt). If the web conversation is not highlighted, then select the web conversation.

  3. When done, click Finish. This will open the Action editor.

  4. From here you will model the implementation of the action. Implementing the Action consists of dropping steps onto the canvas, configuring the steps, and stringing the steps together into a flow. The following diagram shows the implementation of the InitConversation action.

    Figure 5.18. Conversation Action: ValidateAppraisal

    Conversation Action: ValidateAppraisal

  5. In this case there are only two steps. Once a step is added the canvas, you can configure the step by double-clicking on the step to open the step properties.

    Table 5.4. Action Implementation: ValidateAppraisal Action

    Step NameStep TypeConfiguration
    Required Fields Specified?
    Decision
    Properties-->Decision Criteria
    • Expression: currentAppraisal.employeeNo != null && currentAppraisal.employeeNo != ""

    Proceed to Confirm Page
    Variable Editor
    Properties-->Variable Editor
    • Variable:project.page = "/confirm"

    Proceed to Edit Page
    Variable Editor
    Properties-->Variable Editor
    • Variable:project.page = "/edit"

    Stop
    Stop
     NoteOptional Text: "This action persists the appraisal to the data source."

    Figure 5.19. Properties: Decision Step - Decision Criteria

    Properties: Decision Step - Decision Criteria

    Figure 5.20. Properties: Variable Editor - Variable Editor

    Properties: Variable Editor - Variable Editor

    Figure 5.21. Properties: Variable Editor - Variable Editor

    Properties: Variable Editor - Variable Editor

  6. A Note can be optionally added to an action to describe the functionality of the action.

2.7. TASK: Add the SaveAppraisal Action

Figure 5.22. Developer View of Application - SaveAppraisal

Developer View of Application - SaveAppraisal

This action handles the logic when the user clicks on the "Next" button, in which case the validated appraisal object should be persisted. This action defers to the Save Appraisal operation that was created in chapter 4. This action will also invoke the InitConversation action which is responsible for getting the application back to the starting state.

Steps:

  1. Right click the on PerformanceMgmt web conversation, and select New-->Action

  2. From the New Action Wizard, enter "SaveAppraisal" for the filename. This will be the name of the new action. The container for this action should be the web conversation(PerformanceMgmt). If the web conversation is not highlighted, then select the web conversation.

  3. When done, click Finish. This will open the Action editor.

  4. From here you will model the implementation of the action. Implementing the Action consists of dropping steps onto the canvas, configuring the steps, and stringing the steps together into a flow. The following diagram shows the implementation of the InitConversation action.

    Figure 5.23. Conversation Action: SaveAppraisal

    Conversation Action: SaveAppraisal

  5. In this case there are only two steps. Once a step is added the canvas, you can configure the step by double-clicking on the step to open the step properties.

    Table 5.5. Action Implementation: SaveAppraisal Action

    Step NameStep TypeConfiguration
    Invoke Save Appraisal Operation
    Invoke Operation

    Properties-->Operation

    • Operation: PAM.AppraisalService.SaveAppraisal

    Properties-->Inputs

    • Input Variable: inAppraisal - Expression: currentAppraisal

    Properties-->Outputs

    • None

    Invoke InitConversation Action
    Invoke Action
    Properties-->Operation
    • Action: PAM.PAMController.PerformanceMgmt.InitConversation

    Stop
    Stop
     NoteOptional Text: "This action persists the appraisal to the data source."

  6. A Note can be optionally added to an action to describe the functionality of the action.

3. View - JSP Pages

The user interface is implemented using JSP pages, which were created at the beginning of the chapter. The WebContent folder holds all JSP pages and web-related resources, including javascript libraries, stylesheets, flash controls, and images. Skyway provides a palette of web controls to build user interfaces. The web controls can be wired to the Web Controller and associated Web Conversations that were defined in an earlier section. Each web control has it's own properties panel for configuring.

You can further augment Skyway's web controls with the additional functionality available from JSP.

3.1. TASK: Implement index.jsp Page

The following figure shows how the index.jsp page will look to the end-user of PAM.

Figure 5.24. index.jsp - runtime view

index.jsp - runtime view

Steps for implementing index.jsp:

  1. The pages are comprised of a combination of html and Skyway web controls. Using the Web Control palette, build the page according to the following listing. Following the listing there is a description of key web controls and their configuration.

    • Skyway Form ( <skyway:form> ) - used to define a form. The action attribute is configured with "/PAM/PAMController/PerformanceMgmt/InitNewAppraisal", the fully qualified path of the web conversation action that will be invoked when the form is posted.

      <skyway:form action="/PAM/PAMController/PerformanceMgmt/InitNewAppraisal">
      ...Form Contents...
      </skyway:form>
      

    • Skyway Button ( <skyway:button> ) - used to provide the user a button to click. The label attribute is configured with "New", the title of the button. To configure the button to submit the form, the type should be set to "submit".

      <skyway:button label="New" type ="submit"></skyway:button>
      

    • Skyway Iterator ( <skyway:iterator> ) - used to define a fragment that should be repeated for as many objects that exist in the collection. This is very useful for listing the contents of a collection. The items attribute is configured with "PAMController.PerformanceMgmt.appraisals", the variable collection that should be iterated. The var attribute is configured to "current", a variable that is used by embedded web controls (see label) to reference an individual object as the collection is iterated.

      <skyway:iterator items="${PAMController.PerformanceMgmt.appraisals }" var="current">
      </skyway:iterator>
      

    • Skyway Label ( <skyway:label> ) - used to output the value of a variable. The value attribute is configured with the variable that should be output. Since this label is referencing a variable from an iterated collection, the variable is referenced as "current.", the var attribute from the iterator web control.

      <skyway:label value="${current.employeeNo}"></skyway:label>
      

    Figure 5.25. index.jsp - full listing

    <%@taglib uri="http://www.skywaysoftware.com/taglibs/core"
    	prefix="skyway"%><%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <skyway:form action="/PAM/PAMController/PerformanceMgmt/InitNewAppraisal">
      <skyway:button label="New" type ="submit"></skyway:button>
    </skyway:form>
    
    <table>
      <tr>
    	<td>Employee No</td>
    	<td>Last Name</td>
    	<td>First Name</td>
    	<td>Design</td>
    	<td>Program</td>
    	<td>Test</td>
    	<td>Comments</td>
      </tr>
    <skyway:iterator items="${PAMController.PerformanceMgmt.appraisals }" var="current">
      <tr>
    	 <td><skyway:label value="${current.employeeNo}"></skyway:label></td>
    	 <td><skyway:label value="${current.lastName}"></skyway:label></td>
    	 <td><skyway:label value="${current.firstName}"></skyway:label></td>
    	 <td><skyway:label value="${current.ratingDesign}"></skyway:label></td>
    	 <td><skyway:label value="${current.ratingProgramming}"></skyway:label></td>
    	 <td><skyway:label value="${current.ratingTesting}"></skyway:label></td>
    	 <td><skyway:label value="${current.comments}"></skyway:label></td>
      </tr>
    </skyway:iterator>
    </table>
    </body>
    </html>
    
    

3.2. TASK: Implement edit.jsp Page

The following figure shows how the edit.jsp page will look to the end-user of PAM.

Figure 5.26. edit.jsp - runtime view

edit.jsp - runtime view

Steps for implementing edit.jsp:

  1. Using the Web Control palette, build the page according to the following listing. Following the listing there is a description of key web controls and their configuration.

    • Skyway Form ( <skyway:form> ) - used to define a form. The action attribute is configured with "/PAM/PAMController/PerformanceMgmt/ValidateAppraisal", the fully qualified path of the web conversation action that will be invoked when the form is posted.

      <skyway:form action="/PAM/PAMController/PerformanceMgmt/ValidateAppraisal">
      ...Form Contents...
      </skyway:form>
      

    • Skyway Input ( <skyway:input> ) - used to solicit input from the user. The path attribute is the path of the variable that the contents of the input field should be stored.

      <skyway:input path="PAMController.PerformanceMgmt.currentAppraisal.employeeNo"></skyway:input>
      

    • Skyway Dropdown ( <skyway:dropdown> ) - used to let the user select one of multiple preset values. The path attribute is the path of the variable that the contents of the selected value should be stored.

      <skyway:dropdown path="PAMController.PerformanceMgmt.currentAppraisal.ratingDesign">
      ...options...
      </skyway:dropdown><br>
      

    • Skyway Option ( <skyway:option> ) - used to specify a preset value for the dropdown control. The label attribute is displayed to the end user, and the value attribute is the value that's submitted for the option.

      <skyway:option label="Exceeds Expectations" value="1"></skyway:option>
      <skyway:option label="Meets Expectations" value="2"></skyway:option>
      <skyway:option label="Does Not Meet Expectations" value="3"></skyway:option>
      

    • Skyway Textarea ( <skyway:textarea> ) - used to solicit input from the user. The path attribute is the path of the variable that the contents of the input field should be stored.

      <skyway:textarea  path="PAMController.PerformanceMgmt.currentAppraisal.comments"></skyway:textarea>
      

    • Skyway Button ( <skyway:button> ) - used to provide the user a button to click. The label attribute is configured with "Save", the title of the button. To configure the button to submit the form, the type should be set to "submit".

      <skyway:button type="submit" label="Next" ></skyway:button>
      

    Figure 5.27. edit.jsp - full listing

    <%@taglib uri="http://www.skywaysoftware.com/taglibs/core" prefix="skyway"%>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <skyway:form action="/PAM/PAMController/PerformanceMgmt/ValidateAppraisal">
      Employee No
        <skyway:input path="PAMController.PerformanceMgmt.currentAppraisal.employeeNo"></skyway:input>
      <br>
      Last Name
        <skyway:input path="PAMController.PerformanceMgmt.currentAppraisal.lastName"></skyway:input>
      <br>
      First Name
      <skyway:input  path="PAMController.PerformanceMgmt.currentAppraisal.firstName"></skyway:input>
      <h2>Ratings:</h2>     
      Design
      <skyway:dropdown path="PAMController.PerformanceMgmt.currentAppraisal.ratingDesign">
        <skyway:option label="Exceeds Expectations" value="1"></skyway:option>
        <skyway:option label="Meets Expectations" value="2"></skyway:option>
        <skyway:option label="Does Not Meet Expectations" value="3"></skyway:option>
      </skyway:dropdown><br>
      Programming
      <skyway:dropdown  path="PAMController.PerformanceMgmt.currentAppraisal.ratingProgramming">
        <skyway:option label="Exceeds Expectations" value="1"></skyway:option>
        <skyway:option label="Meets Expectations" value="2"></skyway:option>
        <skyway:option label="Does Not Meet Expectations" value="3"></skyway:option>
      </skyway:dropdown><br>
      Testing
      <skyway:dropdown  path="PAMController.PerformanceMgmt.currentAppraisal.ratingTesting">
        <skyway:option label="Exceeds Expectations" value="1"></skyway:option>
        <skyway:option label="Meets Expectations" value="2"></skyway:option>
        <skyway:option label="Does Not Meet Expectations" value="3"></skyway:option>
      </skyway:dropdown>
      <br>
      Comments:
      <skyway:textarea  path="PAMController.PerformanceMgmt.currentAppraisal.comments"></skyway:textarea>
      <br>
      <skyway:button type="submit" label="Next" ></skyway:button>   
    </skyway:form>
    </body>
    </html>
    
    

3.3. TASK: Implement confirm.jsp Page

The following figure shows how the confirm.jsp page will look to the end-user of PAM.

Figure 5.28. confirm.jsp - runtime view

confirm.jsp - runtime view

Steps for implementing confirm.jsp:

  1. Using the Web Control palette, build the page according to the following listing. Following the listing there is a description of key web controls and their configuration.

    • Skyway Form ( <skyway:form> ) - used to define a form. The action attribute is configured with "/PAM/PAMController/PerformanceMgmt/SaveAppraisal", the fully qualified path of the web conversation action that will be invoked when the form is posted.

      <skyway:form action="${webContextRoot}/PAMController/PerformanceMgmt/SaveAppraisal">
      ...form...
      </skyway:form>
      

    • Skyway But