® ibm software group © 2006 ibm corporation egl programming model these slides walk you through...

42
® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise Generation Language – including the programming model, project file organization, and logic “parts”.

Upload: simon-carter

Post on 13-Dec-2015

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

®

IBM Software Group

© 2006 IBM Corporation

EGL Programming Model

These slides walk you through the concepts and vocabulary the make up the Enterprise Generation Language – including the programming model, project file organization, and logic “parts”.

Page 2: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

2

Course

RBD and Course Setup

RBD Workbench

EGL/Web QuickStart

Programming in EGLProgramming in EGL

Database and File Access

EGL and Services (SOA)

Calling External Languages From EGL

EGL and Batch Applications

Appendices

Units:

RBD/EGL ProgrammingRBD/EGL Programming

Page 3: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

3

UNIT

The EGL Programming Model – Terms/ConceptsThe EGL Programming Model – Terms/Concepts

EGL Data Parts and Assignment Statements

EGL Conditional Logic and Looping Statements

The EGL Built-in Functions and Date Math

Topics:

Programming in EGLProgramming in EGL

Page 4: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

4

Programming in EGLTo master EGL programming you will need to learn the following EGL topics:

File Model Parts Concept Programming Model Namespace Concept Editor Instruction set, specifically:

Data declarations– Primitives– Records– DataItems– Arrays

Logic constructs, specifically– Assignment statements– Conditionals– Looping statements– EGL System Libraries

EGL data access verbs– SQL database statements– Non-SQL files

Calling external programs, from EGL Debugger

As a broad and deep platform for developing business applications that generate to both mainframe (traditional) and server (contemporary) run-times, EGL has introduced a few new programming constructs, in order to simplify your work.

Additionally, the EGL programming language has been kept procedural (for legacy programmers) in nature, yet growing into a “modern” vocabulary – which allows you to leverage advances in computer language engineering, since the days of COBOL, RPG, i4GL, etc.

Page 5: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

5

The EGL File Model and File Types

Your EGL projects will contain a number of different file types:

ProgramsPrograms Traditional business logic files with a single entry point. Calling (main) or called subroutines.

LibrariesLibraries Business logic files that contain multiple functions, each of which can be called separately by other Logic Parts.

ServicesServices Business logic files that are like Libraries, except they can be published and made available as Web Services –

and called by other Logic Parts. JSFHandlersJSFHandlers

Specialized business logic files that manage the functionality required by JSF web pages. JSFHandlers typically call programs, library and service functions.

BIRTHandlersBIRTHandlers Specialized business logic files that manage the functionality required by reporting tools such as BIRT and

Jasper Build files

EGL files that provide specifications for language generation (to Java, or COBOL)

Related file types are often organized within an EGL package, which is essentially a folder that acts as a unit of scope for file management.

- See the Help topic: Introduction to EGL files

Page 6: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

6

The EGL File Model Hierarchy – Organization of Folders and FilesProjectWorkspace

ProjectA

…\EGLSource\ \package1\ File1.egl File2.egl File3.egl \package2\ File5.egl File6.egl EGLBuild

file.eglbld …

ProjectB

\EGLSource\ \package3\ File7.egl File8.egl

\package4\ File9.egl

EGLBuild file.eglbld …

Project Explorer manages your files and folders (called packages) in a hierarchical tree

Notes: Your project Workspace, all projects and all packages are physically maintained on your PC as file folders.

If a file that resides under \package1\ needs to reference EGL business logic in a file that resides under \package2\ (a folder at the same level, as shown on the right)

You will need an EGL “import” statement to allow the EGL parser to find the file. This is because packages act to maintain “scope” – a concept we will discuss in a minute.

Page 7: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

7

The EGL Part Model In order to allow us to group related EGL language keywords into a higher level of abstraction, EGL introduces

the notion of “parts” as an organizational meta-concept. Specifically, EGL understands the notion of: Data Parts:

Record DataItem EGL DataTable

Logic Parts: Function Program Library Service Handlers: JSFHandler, ReportHandler, Forms

Generate-able Parts Any EGL Part that is it’s own file (ending in .eglegl) that gets generated to COBOL or to Java

Build Parts An EGL file that ends with the extension .eglbldeglbld – Build parts control the generation process and run-time behavior

By using the term “parts” we can collectively refer to a number of language abstractions as one term. Also - the product documentation references parts ubiquitously

- See the Help topic: Introduction to EGL Parts

Page 8: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

8

EGL Parts – Source Code Reuse and Productivity

As soon as an EGL Logic or Data part is successfully saved and validated, it is entered into an EGL “Parts Dictionary”, maintained for your current workspace. EGL Data and Logic parts (Records, DataItems, Programs, Functions, etc.) in this dictionary are accessible using Content Assist (Ctrl/Spacebar) when you edit your code.

Ctrl+Spacebar

Page 9: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

9

The EGL Program Model

All EGL business logic files are organized in a consistent, structured model, consisting of five source code areas, or segments:

1. Package statement – what is my parent package/folder?

2. Import statements – what other folders do you want to reference EGL source from

3. Part Type statement – what kind of Generate-able Part am I – including any EGL Properties that refine my run-time behavior

4. Global data variable declarations – DeclarationsThat can be referenced from any Function in the Namespace

5. Function declarations – operational EGL statements – business logic

1.

2.

3.

4.

5.

Page 10: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

10

Namespace – AKA “scope”

Like almost all contemporary languages, EGL adheres to the concept of a Namespace – which means essentially, “What can be referenced by an EGL statement in a file?” From our example shown here … note the following:

Any statement in any function in the updatecustomer2 JSFHandler part can reference: (Global) variables customer and status All three functions in this file

Additionally, any statement in any function can reference any defined Logic or Data part in any file under: The jsfhandlers package Any file in an imported package (there are

four imports in this file)

If you attempt to reference an EGL Part that is outside of the Namespace (not in the current file, and not a defined part in the jsfhandlers package, or in any of the import packages) you will get a “cannot be resolved” syntax error, when you try to save your work.

See Slide Notes – for additional info on Namespace

Page 11: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

11

EGL Functions A function is the fundamental business logic unit in

an EGL Logic Part. Functions contain a series of EGL statements and can include the following elements: Function namename – unique within the Namespace,

followed by parentheses () A set of positional parametersparameters, enclosed in the

parentheses, each of which corresponds to an argument (and its data type) passed when the function is called by another function.

A return typereturn type, which describes the type of data that the function returns to the calling function.

A set of local variableslocal variables, each of which has meaning within the function only.

EGL statements – as per your business logic requirements

An end delimiter.

Functions are invoked by simply specifying their underlying part and function name, and passing parameters as defined

Customerlib.DeleteCustomer(customer, status);

Page 12: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

12

Other Language Concepts Most EGL statements are terminated

with a semi-colon. A few statements are terminated with the reserved word: end - including:

Part and Function declarations Conditional and Looping statements

EGL is a case-insensitive language – except where it interfaces with Java – examples: Page Data Variables and Functions, etc.

You can comment on a single line with: //

You can comment across lines with /*……*/

Variable, function and part identifiers: Can be from 1 – 128 characters long Must start with letter or underscore Cannot be an EGL reserved word Should not be the same as a defined

Logic or Data Part

Statement order in an EGL file: Package must be the first (non-comment)

statement in your file. Followed by Import statement(s) Part Type declaration Global Data variable declarations EGL Function declarations

Page 13: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

13

JSFHandler Part A JSF Handler part is an EGL Logic

Part that is customized to control a Web page at run time. JSF Handlers contain your business logic functions and specialized functions that run automatically at certain points in a Web page's life (onConstruction() is one, please see the product help documentation for more info.)

Use EGL functions in a JSF Handler to validate or change the data that a user types into a Web page, to assign values to JSF fields, to respond to a user's actions on the page, or to forward to a different page.

Complex and lengthy business logic should be coded in EGL Libraries, Services and Programs and called from JSF Handlers.

EGL global data variables (coded after the JSFHandler statement and outside of a Function) can be bound to JSF page controls.

Page 14: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

14

Program Part

A Program part is a generate-able logic part with a single point of entry and a required function called main(), which represents the logic that runs at program start up.

A program can include other functions an can access functions that are outside of the program. The function main() can invoke those other functions, and any function can call other programs, Libraries or Services – but not JSFHandlers.

Programs can be defined Without parameters (Main programs) With parameters (Called programs)

Main programs run when started by an operating system command or a transfer from another main program. They are used primarily for “batch” , IMS or CICS applications.

Called programs are invoked from other programs via the callcall statement. Example of an EGL Called ProgramExample of an EGL Called Program

Page 15: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

15

Library Part

A Library part is another generate-able part, similar to an EGL Program Part, except that it supports sharing individual functions and variables through direct references.

When you imported the database schema awhile back, the import process created a number of EGL Libraries with functions you called in other workshops and labs.

EGL provides a number of system libraries containing commonly-required functions (date/time handling routines, string functions, math library functions, etc.). These will be covered in a section later on in the course.

You can also create your own libraries of frequently used functions. Example of an EGL LibraryExample of an EGL Library

Page 16: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

16

Service Part

A service is similar to a library, with the major exception that a service may be located remotely from its client.

The client – which can be a program, JSF handler, library, or other service - uses (invokes) the functions defined in the service.

Services have one or more public functions that contain business logic. Once you have written the business logic, you can deploy the service as one of the following: an EGL Java™ service a Web service an EGL COBOL service a CICS® Web Service

In general, you create a Service part when you want to make your business logic available to other programs, either locally or remotely, in an encapsulated way.

Example of an EGL ServiceExample of an EGL Service

Page 17: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

17

The EGL File Model and File Types – Calling …vs… Called Routines and Functions

Library1Library1Function4Function4 Library2.Function10Library2.Function10Function5Function5Service1.Function7Service1.Function7Function6Function6 Call Program2Call Program2

Service1Service1Function7Function7Function8Function8 Call Program2Call Program2 Service2.Function9Service2.Function9

JSFHandlerJSFHandlerFunction16Function16 Call program1…Call program1… Library1.function4…Library1.function4…Function17Function17 Service2.Function9Service2.Function9Function18Function18

Program1Program1Main()Main()……Function19Function19 Call program2…Call program2…Function20Function20

Library2Library2Function10Function10 Service2.Function9Service2.Function9

Service2Service2Function9Function9Function14Function14Function15Function15

Program2Program2Main()Main() Library1.Function6Library1.Function6Function1Function1 Service2.Function15Service2.Function15

JSFHandlers can call/invoke• Programs – at the program level• Libraries – through Function calls• Services – through Function calls

Programs, Libraries, and Services can invoke other:• Programs – at the program level• Libraries – through Function calls• Services – through Function calls

… But can notnot invoke JSFHandlers

Page 18: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

18

Structured Programming in EGL – Best Practices

Some simple concepts to keep in mind, when designing your business logic solutions: Break-up (formulate) your logic into EGL functions EGL functions should be between 10 and 30 lines of code (best practice) Almost all substantial business logic belongs in functions within EGL Libraries

and Services All data access logic All substantial business computations

JSFHandlers should contain only: Page display (U.I.) logic Navigation logic Screen-specific edits (and consider moving these to Libraries as well) Transaction logic (commit, rollback, etc.)

EGL ProgramsPrograms are used for: Batch processing (the “main” module, called from the Operating System) COBOL Generation – for traditional online processing

DataItems should be used for: Formatting As much validation and editing as possible

Page 19: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

19

EGL and “Inheritance”

Inheritance is an O-O principle that promotes code reuse EGL supports “object-based” not object-oriented inheritance through:

DataItem properties Parts Dictionary – Logic parts/Data parts

Variable references to DataItems in records and fields. Can:

• Inherit properties• Over-ride properties

Workspace

Reuse existing Parts.• Library, Service and Program functions• DataItems, Records, DataTables

BusinessBusinessLogicLogic

DataItemsDataItems

PartsPartsDictionaryDictionary

BusinessBusinessLogicLogic

Page 20: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

20

Workshops for this Topic

Using RBD tooling and EGL, follow the steps which start on the next slide and create the following software architecture scaffolding and EGL Logic Parts:

Packages – under \EGLSource\ for back-end business logic – for organizing logic parts in your project

Libraries Programs Services A JSFHandler that calls the back-end logic components

You will test your work, running a simple Web Page that calls functions in all of the above logic parts.

JSPJSPPagePage

EGLEGLProgramProgram

EGLEGLJSFHandlerJSFHandler

EGLEGLLibraryLibrary

FunctionFunction

EGLEGLServiceService

FunctionFunction

Page 21: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

21

Create EGL Packages

Create the following EGL packages, all under the \EGLSource\ folder: programsprograms servicesservices librarieslibraries datadata EGL DataTables EGL DataTables (if time permits)

Notes: All package names must be lower-caselower-case You will create five new packages, as shown here

(From Project Explorer) Right-click over \EGLSource\\EGLSource\

Select New New EGL Package EGL Package Name the packages (one at a time):

data, datatables, libraries, programs, and services

Example – creating the programs package

Page 22: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

22

Create an EGL Library Create the following EGL Library and function under the \EGLSource\libraries\ folder:

Right click over the \EGLSource\libraries\ folder and select: New > Library Create a basic library. The EGL source file name should be: library1library1

Using the EGL Editor, modify the text so that library1 contains the code shown below:

Initialized msg string global variable

Function that takes a parameter in And concatenates the parameter with the msg data

And returns – to the calling program

Press Ctrl/S when finished, to Save and Validate your EGL coding

Page 23: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

23

Create an EGL Program Create the following EGL Program and function under the \EGLSource\programs\ folder:

Right click over the \EGLSource\programs\ folder and select: New > Program Create a called program

The EGL source file name should be: program1program1 Using the EGL Editor, use Content Assist, and typing . Modify the text so that program1 contains the code shown below:

Program Logic Part with string parameter

Initialized msg string global variable

Concatenate the parameter with the msgmsg data Invoke the Library function you just created

Press Ctrl/S when finished, to Save and Validate your EGL coding

Page 24: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

24

Create an EGL Service Create the following EGL Service and function under the \EGLSource\services\ folder

Right click over the \EGLSource\services\ folder and select: New > Service The EGL source file name should be: service1service1

Using the EGL Editor, modify the text so that service1 contains the code shown below:

Initialized msgmsg string global variable

Function that takes a parameter in And concatenates the parameter with the msgmsg data

And returns – to the calling program

Press Ctrl/S when finished, to Save and Validate your EGL coding

Page 25: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

25

EGL Service Deployment Descriptors EGL Services have their own special resource management file called a Deployment Descriptor, which allows you to optimally generate and deploy to different run-time environments. When you create a new EGL project, you have the option of asking the tooling to create a new service descriptor for you (we suggest you let

the tooling do this – although it’s not “rocket-science” to create one manually.

After you’ve finished creating your 1st EGL Service you need to register your services to the project’s deployment descriptor by following these steps:

1. From Project Explorer, open: EGLWeb.egldd (it’s towards the bottom of the \EGLSource\ folder)

2. From the EGL Deployment Descriptor Overview, Click the Service Client Bindings Tab (the second-from-left tab on the bottom of the window)

3. From Service Client Binding Configuration, click: AddAdd

4. From Add a Service Client Binding, click: EGL Binding then click Next >

5. From: Add an EGL Binding, click Browse and Select service1service1

6. Click Finish Finish and press Ctrl/S press Ctrl/S to save your changes

Page 26: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

26

Generate Your Project

In order to produce the executable code for your application (whether COBOL or Java) you need to generate your EGL resources. Conceptually this can be depicted as…

Right-click Right-click overover EGLWeb EGLWeb, and select, and select

GenerateGenerate

Page 27: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

27

Create a .JSP Page and JSFHandler – 1 of 3Steps: Right click over the \WebContent\ folder and select: New > Web Page

The file name should be: jsfhandlerjsfhandler11.jsp.jsp Don’t forget to add the .jsp.jsp extension And DON’T name it: jsfhandler.jsp

– Why not? … see ***Notes Expand: My TemplatesMy Templates Select: theme/A_Gray.htpltheme/A_Gray.htpl

From Page Designer, modify the default header text.

Right-Click and select Edit Page Code

Page 28: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

28

Create JSFHandler – 2 of 3 Add the following statements to the default JSFHandler

(shown in the screen capture and notes below)

Use Content Assist to create the calls to the program and service

(Ctrl/Spacebar)

Press Ctrl/Shift/F to format, then Ctrl/S when finished, to Save and Generate your EGL code

String global variables Service variable declaration

Custom EGL Function Assignment statement

Call to your program Invoke service function

Page 29: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

29

Create the .JSP Page from the JSFHandler Variables – 3 of 3 From Page Designer,

1. Select the two fields in Page Data. Drag & Drop them on the page to create an input and an output control as shown below.

2. Expand the Actions folder, and drag the calledModules() function on top of the Submit Button

Page 30: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

30

Run the Page

Right-click over the page in the Content Area and select: Run on Server…Run on Server…

Enter an initial value for Fieldin and click Submit

Verify your results – note the message text returned from the called routines

Page 31: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

31

Generate and Project Clean

From time-to-time you will need to CleanClean your work-space projects - delete all generated J2EE resources and rebuild them from their EGL sources) – and GenerateGenerate your project: re-create all EGL (batch and J2EE) from their EGL source files.

To CleanClean your projects: Pull-down the Project menu Select Clean…

(typically) Select clean all projects in your workspace

To GenerateGenerate your project: From Project Explorer – Right-click over the Project Icon Select Generate

To save time (if you only need to generate or re-generate a single EGL file), you can Generate individual resources (like EGL Packages, Programs, Services and Libraries) With your mouse-focus inside the file, press: Ctrl/GCtrl/G

*** See Notes*** See Notes*** See Notes*** See Notes

Page 32: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

32

The “Easy Button” – or Buttons

The EGL editor provides many hot-key combinations that improve productivity:

Ctrl/SCtrl/S - Save and validate your EGL statements in your source file

Ctrl/GCtrl/G – Generate your EGL to either Java or COBOL

Ctrl/Shift/FCtrl/Shift/F – format the source code in the current file

Ctrl/Shift/OCtrl/Shift/O – Resolve any missing import statements in your source file

All of these are available after you’ve set your mouse cursor focus into the EGL source file (1. set cursor focus; 2. press one of the above hot-key combinations)

Page 33: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

33

The Rest of the “Easy Buttons” – (Ctrl/”whatever”)

The Eclipse editor provides a much larger list of hot key combinations, available from anywhere in your source by pressing: Ctrl/Shift/LCtrl/Shift/L

Page 34: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

34

The EGL Editor Keyboard Shortcuts

Many developers – when writing business logic tend to want to use their keyboard skills exclusively.

If you fall into this category, here is a list of specific EGL editing keyboard shortcuts you can use for common code development tasks

Page 35: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

35

OPTIONAL Lab – Check Out the Parts/Navigator Menu

There is a Parts selection dialog available from the Navigate menu, which allows you to view all of the parts in your EGL Parts Dictionary, and search/open them in the Content Area.

From the RBD menu bar, pull-down Navigate Or from anyplace in the product, press:

Ctrl/Shift/N

Type a letter – or you can mix letters with wildcards

Select and open the part

Page 36: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

36

OPTIONAL Lab - Check Out “F3” – Open Selection

For every defined element of your EGL Logic and Data Parts (including all variable and function declarations) you can: 1. Highlight a reference, 2. Press F3 on your keyboard – to open that reference in the Content Area (this is called Open on Selection in the Context menu).

From Project Explorer, open: updatecustomer2.eglupdatecustomer2.egl Highlight any called Library function and press F3F3

F3

Page 37: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

37

Are We On Track?From the source file here Pick out (identify) the following:

Comment EGL identifier EGL statement delimiter EGL function Global variable declaration Local (inside a function) declaration Library (function) call A literal The statement that describes which

folder the source is in The statement that provides

reference-ability to EGL source files in other folders

The statement that defines the type of file this is

An EGL conditional statement And EGL assignment statement

See – this stuff is not so hard and really, not all that much is new, is it?

Page 38: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

38

Are We on Track?

Match the following definitions and terms – note that some terms may have more than one definition and vice versa

1. JSFHandler ___ A folder that contains files or sub-folders within a Project – also a unit of Namespace scope

2. Package ___ A file that contains generation options and settings

3. EGL Logic Part ___ An EGL Logic Part that can contain multiple Functions, each of which, can be called separately

4. Service ___ The first line in any EGL Logic Part. It sets the initial scope for what can be referenced throughout the file.

5. Library ___ An EGL logic part that manages program/web page interaction

6. Program ___ An EGL logic part that controls the compilation (build) process

7. EGL Data Part ___ The parser’s concept of what can be referenced within an EGL Logic Part (what files and folders etc. are “in scope”)

8. Namespace ___ EGL statements that provide reference-ability to files within other folders of your project

9. EGL Parts Dictionary ___ An EGL Logic Part similar to a Library that can be deployed and called across run-time platforms. Also known as a Web ______.

10. Import statement ___ The collective name by which EGL programs, libraries, services, etc. are referred to – especially in the doc

11. Function ___ The collective name by which EGL Records, DataItems and DataTables are referred to

12. Build File ___ All of the EGL parts that have been successfully coded and saved in your workspace, and now can be referenced using Content Assist

Page 39: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

39

EGL Language General – (True/False)EGL Language General – (True/False)1. Variables declared inside of a function are known as “Global Variables”“Global Variables” - and can be used to

create JSF controls. They can also be accessed from any function inside the file2. Every EGL logic part has the same structure (from top to bottom in the file):

Package statement – that identifies under which folder the file resides Import statements – necessary if your source references a file from another parent folder fileType (Library, Service, Program, Handler, etc.) – which uniquely identifies/names the file and sets specific file

properties Global (Page Data) variables Business Functions

3. File and variable properties are contained inside curly braces { { …… } }4. All EGL business logic is contained inside logic functions5. All EGL statements end with a semi-colon6. Almost all EGL statements end with a semi-colon. The ones that don’t end with a semi-colon include:

IfIf statements For and whilehile loops EGL logic functionsfunctions EGL partsparts (like JSFHandler, Program, Service, Record, etc.)

7. EGL Deployment Descriptor files are used to describe how EGL service applications are linked to the clients that call them, and vice versa

8. EGL programs contain functions that can be called individually from other logic parts9. EGL variable declarations are coded like Java declarations: variableType variableName;variableType variableName;10. EGL Build Files are used to specify code generation options.

Locate your projects EGL Build file. It’s named: EGLWeb.eglbld12. All .EGL files must be contained under the \EGLSource\ folder in your project (most likely in a sub-

folder within \EGLSource\)13. Okay we lied, EGL Services and Libraries contain functions that can be called individually!

Review Questions – Be able to answer and to demonstrate your understanding through Workbench use

Page 40: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

40

Checkpoint – EGL Project and File Types(From Project Explorer)

1. Create a new EGL Library in the \libraries\\libraries\ folder named: tempLibtempLib

2. In this library add two new functions and a record, you will use to convert Fahrenheit to Celsius and vice versa. Note – add the record AFTER the final Library endend statement (as shown here)

Also note that you enclose variable extended properties (like ZeroFormat = yes) in curly braces {{ ……. }} - not parenthesis

3. Save (Ctrl/SCtrl/S) and Generate (Ctrl/GCtrl/G) the library

Page 41: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

41

Optional Workshop –

converter.jspconverter.jsp Create the following new web page:

Name: converter.jspconverter.jsp

Layout

EGL Code

Don’t forget to press Ctrl/Shift/OCtrl/Shift/O – to organize the imports

Notes (and optional exercises): Use of EGL Basic Record for U.I. (tempRec) Use of EGL Properties in the record:

ZeroFormat – displays zeros, not blanks Sign – displays negatives with leading

dash You could turn the Library functions into calls

to a local EGL service

Page 42: ® IBM Software Group © 2006 IBM Corporation EGL Programming Model These slides walk you through the concepts and vocabulary the make up the Enterprise

42

Now that you have completed this topic, you should be able to:

Define what EGL Logic, Data, Build and Generate-able parts are Define the purpose for the following types of Logic parts:

Program Library Service JSFHandler

Define what is in a Build file and what is its purpose Describe the following data parts:

DataItem Record

Create packages

Topic Summary