< Previous | Next >

Lesson 2: Set up the workspace

Before you write your logic, create two EGL projects and import the Dojo samples.

An EGL application is organized in one or more projects, each of which is a physical folder in the workspace. A project contains an EGL source folder that is provided for you, and that folder contains one or more packages, which in turn contain EGL source files. This hierarchy is basic to your work in EGL: a project, then an EGL source folder, then a package with EGL source files.

The EGL source files include EGL parts, which are type definitions that you create. For example, a Service part contains logic, and a Record part can be the basis of a variable that you declare in your Service part.

Packages are important because they separate parts into different contexts, or namespaces:
  • A part name might be duplicated in two different packages, and any EGL source code can reference each part precisely. The main benefit of namespaces is that different teams can develop different EGL parts without causing name collisions.
  • Each part name in a given package is unique within that package:
    • A part in one package can easily reference another part in the same package by specifying the part name. For example, here is a declaration of a record that is based on the Record part MyRecordPart:
      myRecord MyRecordPart{};
    • A part in one package can also reference a part in a second package by giving the package name and part name, or by a shortcut that involves importing the part. This tutorial gives examples.

One project can reference the parts in a second project, but only if the EGL build path of the referencing project identifies the referenced project. Again, this tutorial gives examples. However, in all cases, avoid using the same package name in different projects, as that usage can cause problems in name resolution.

Your next task in this tutorial is to create the following projects:
MortgageServiceProject
Holds an EGL Service part and related definitions
MortgageUIProject
Holds the Rich UI handlers and related definitions

You can include all your code in a single project, but the separation shown here lets you easily deploy the two kinds of code in different ways.

Create an EGL service project

  1. If you are in a workbench perspective other than EGL, change to the EGL perspective by clicking Window > Open Perspective > Other > EGL. The perspective icon is in the upper-right corner of the workbench.
    The EGL icon indicates the EGL perspective and is displayed on a tab that is underneath the minimize, maximize, and close icons.
  2. Click File > New > EGL Project, or click the New EGL Project icon on the menu bar.
    The new project icon is the first of four in the second group of icons in the menu bar.
  3. In the EGL Project window, enter the following information:
    1. In the Project name field, type the following name:
      MortgageServiceProject
    2. In the EGL Project Types section, click General Project.
      The New EGL Project window with the Project name “MortgageServiceProject.”
    3. Click Next.
  4. In the second EGL Project window, the defaults that EGL provides should be correct. Verify the following information:
    1. The Target runtime platform is Java™. This setting indicates that EGL generates Java source code from your EGL Service part.
    2. Under Build descriptor options, the Create a build descriptor radio button is selected. Build descriptors control the generation process. Because you are creating a separate project for your service, you can use the default build descriptor that EGL creates for you.
  5. Click Finish.
EGL creates a project named MortgageServiceProject. Note the folders inside the directory:
EGLSource
Put your packages and source files here.
EGLGen/JavaSource
EGL places the Java files it generates here.
JavaSource
Put any custom Java source files here. These files are not overwritten during the generation process.
JRE System Library
EGL uses this folder for JAR files that support the Java Runtime Environment.
The Project Explorer view shows the new project and folders.

Create an EGL Rich UI project

  1. Click the New EGL Project icon on the menu bar.
  2. In the New EGL Project window, enter the following information:
    1. In the Project name field, type the following name:
      MortgageUIProject
    2. In the EGL Project Types section, click Rich UI Project.
      The EGL Project window with the Project name "MortgageUIProject."
    3. Click Next.
  3. In the second EGL Project window, the defaults that EGL provides should be correct. Verify the following information:
    1. Use the default location for the project is selected.
    2. The Widget libraries list contains the following projects:
      • EGL Rich UI widgets
      • EGL Dojo widgets
    3. In the EGL project features group, Create an EGL deployment descriptor is selected.
  4. Click Next.
  5. On the EGL Settings page, select MortgageServiceProject. The service project is added to the build path for the new project, so that the UI project can use parts that are defined in the service project.
  6. Click Finish.
EGL creates a project named MortgageUIProject and adds support projects to the workspace for Rich UI, Dojo Widgets, and the Dojo runtime library. In addition to the directories that EGL created for the General project, a Rich UI project includes the following directory:
WebContent
Contains support files, such as cascading style sheets (CSS) and images.
The Project Explorer view shows the new project and folders.

Import the EGL Dojo widgets sample

  1. From the top menu of the workbench, click Help > Help Contents.
  2. In the Help contents, expand Samples > Technology samples > EGL and click EGL Dojo widgets.
    The expanded Samples menu.
  3. In the Content pane, click Get the sample.
    The Content pane
  4. In the Import window, the default values are correct. Click Finish.
The latest version of the com.ibm.egl.rui.dojo.samples project is added to your workspace.
The Dojo samples project in the Project Explorer view.

Change your build path for MortgageUIProject

The EGL build path determines the projects that EGL examines when trying to resolve references in your logic. To add the project that you just imported:

  1. In the Project Explorer view, right-click MortgageUIProject, and then click Properties. On the left side of the Properties for MortgageUIProject window, click EGL Build Path. EGL displays a list of the projects in your workspace.
  2. Select the com.ibm.egl.dojo.samples project. You do not need to select the com.ibm.egl.dojo.widgets project because it is already in the build path of the com.ibm.egl.dojo.runtime.local project. The finished build path window should look like the following image:
    Four of the five projects are selected.
    These selections mean that when you organize the import statements that provide other details to your programs, EGL will look in all of the selected projects to resolve references.
  3. Click OK.

Lesson checkpoint

In this lesson, you completed the following tasks:
  • Created an EGL project for the mortgage service
  • Created an EGL project for the Rich UI application
  • Imported the EGL Dojo samples project
  • Adjusted the EGL build path for the second project

In the next lesson, you create a dedicated service to calculate a monthly mortgage payment.

< Previous | Next >

Feedback