® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

389
® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development

Transcript of ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

Page 1: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

®

IBM Software Group

© 2009 IBM Corporation

Rational Business Developer

EGL Rich UI Development

Page 2: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

2© 2009 IBM Corporation

IBM Trademarks and Copyrights

© Copyright IBM Corporation 2007,2008. All rights reserved.

The information contained in these materials is provided for informational purposes only, and is provided AS IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, these materials. Nothing contained in these materials is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. References in these materials to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates.

This information is based on current IBM product plans and strategy, which are subject to change by IBM without notice. Product release dates and/or capabilities referenced in these materials may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way.

IBM, the IBM logo, the on-demand business logo, Rational, the Rational logo, and other IBM Rational products and services are trademarks or registered trademarks of the International Business Machines Corporation, in the United States, other countries or both. Other company, product, or service names may be trademarks or service marks of others.

Page 3: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

3© 2009 IBM Corporation

Contributing Authors

Scott Pecnik, Chris Laffra and Jon Sayles – primary content and courseware developers

Ancillary contributors: William Smythe/IBM, Brian Svihovec/IBM, Michael Virga/IBM, Yann Lerouzic/Morpheus

Consulting, U.K., Mike Brouwers of ASIST, Kendall Coolidge, Nick Leonessa, Oleg Arsky/Synchrony Systems, Daniel Beauregard, CCB Associates, Inc., Arco van der Velden/Synobsys Nederland B.V., Ulf Buchner/Synobsys Nederland B.V.,

Page 4: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

4© 2009 IBM Corporation

Course Details

Audience This course is designed for application developers who have programmed in a 3rd

or 4th generation language – and who need to build Web 2.0/Rich User Interface applications using EGL.

Prerequisites Basic PC and mouse-driven development skills are assumed. It is assumed that you have taken the EGL Foundation Class, and have a

comfortable understanding of eclipse, the EGL language, SQL, services (including Web Services) and web technology

Alternatively, if you have the equivalent EGL work experience doing production dynamic content web application development using Eclipse, EGL and web applications that should be sufficient

An understanding of basic HTML is helpful HTML syntax HTML tables HTML components such as input fields, radio buttons, etc.

Page 5: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

5© 2009 IBM Corporation

Course

Units:

RBD/EGL DevelopmentRBD/EGL Development

What is Web 2.0?What is Web 2.0?

Programming in EGL Rich UI

Learn EGL Rich UI

Appendix

Page 6: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

6© 2009 IBM Corporation

History of Web 2.0

The term “Web 2.0” was first coined by O’Reilly Media in 2003.

It was then popularized by the first Web 2.0 conference in 2004.

The term implies a new version of the internet, but that is not the case

According to Tim O'Reilly, "Web 2.0 is the business revolutionbusiness revolution in the

computer industry caused by the move to the internet as platforminternet as platform, and an attempt to understand the rules for success on that new platform.“

Moral: Web 2.0 is not really all that new

Page 7: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

7© 2009 IBM Corporation

Web 2.0 - Google Definition

Web 2.0Web 2.0 is a term often applied to a perceived ongoing transition of the World Wide Web from a collection of websites to a full-fledged computing platform serving web applicationsweb applications to end users.

Ultimately Web 2.0 services are expected to replace desktop computing applications for many purposes.

Web 2.0 is becoming synonymous with RIARIA (Rich Internet Application)

Source: http://alexzelder.files.wordpress.com/2007/04/google_logo

1.jpg

Expectations

Page 8: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

8© 2009 IBM Corporation

Web 2.0 – Unofficial IBM “Business Oriented Definition”

An important trend in delivering software applications

An enabler for richricherer web applications New business models Peer-to-peer user participation New technologies Interactive filtering, presentation, data entry

A combination of core technology components Rich user experience (maps, grids, animation, D&D, etc) Loose-coupling, composite applications via reuse and “mash-ups” Standards (SOAP, REST, JSON, Atom, etc)

Page 9: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

9© 2009 IBM Corporation

Web 2.0 technologies highlight the next pendulum swing between client and server function.

ClientClient ServerServer

Mainframe computing“Dumb” little green screen clientsOmnipotent big mainframe servers

Client-server computing“Smart” Personal Computer clientsSimple file and database servers

Web (1.0) computingLight Web Browser clientsRich application and database servers

Web 2.0 computingRich Internet Application clientsLighter application and database servers

Web 2.0 and the Pendulum Swing – between Client and Server Computing

TUI

CUI

JSF

Rich UI

Page 10: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

10© 2009 IBM Corporation

Web 2.0 Application Characteristics

Rich user experience

Minimal page transitions

Dynamic content

Data asynchronously retrieved

via REST or SOAP service calls

Client-side validation

User encouraged to add value

Simplified user interface

Integration of relevant data from multiple sources – “mash-up”

Page 11: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

11© 2009 IBM Corporation

“Mashups” – 1 of 2

Google Map

Hotel information — separate database

Directions — come from somewhere else

Send to a phone —Additional functionality

Refers to the design and development pattern of combining and Refers to the design and development pattern of combining and custom “widgets” in a web application. custom “widgets” in a web application.

The rendered web application mashes-up (contains) relevant and The rendered web application mashes-up (contains) relevant and related views of data on-screen for effective presentationrelated views of data on-screen for effective presentation

Why?

Rapid application development

Reuse existing services

Avoid reinventing the wheel

Empowers users

Why?

Rapid application development

Reuse existing services

Avoid reinventing the wheel

Empowers users

Page 12: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

12© 2009 IBM Corporation

“Mashups” – 2 of 2

Mash-ups can Mash-ups can also be loosely also be loosely related views related views

Think of a Think of a “Portal” “Portal” consisting of consisting of many combined many combined mini-pages, mini-pages, instead of a instead of a single-purpose single-purpose web page like:web page like: LoginLogin

RegistrationRegistration

etc.etc.

Page 13: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

13© 2009 IBM Corporation

Technology Attributes of Web 2.0/Rich Internet Applications

RSS/ATOM allows someone to link not just to a page, but to subscribe to it, with notification every time that page changes.

Users must be treated as co-developers, in a reflection of open source development practices. The open source dictum, "release early and release often”

“DATA is the new HTML." Database management is a core competency of Web 2.0 companies.

XML or JSON data over HTTP, in a lightweight approach sometimes referred to as REST (Representational State Transfer) as an alternative to SOAP.

AJAX incorporating: XHTML and CSS, DOM, XML and XSLT, XMLHttpRequest and JavaScript allowing information to be mashed up into new interactive portals."

Feeds

Perpetual Beta

Info-ware

LightweightProgramming

Model

Rich UserExperience

Page 14: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

14© 2009 IBM Corporation

Web 2.0 and Community

Web 2.0 websites are often based on community Some examples of Web 2.0 sites are: Facebook,

Digg, Yelp, and Twitter (see slide ***Notes***Notes for url’s) All of the above web sites rely on the community to

submit content.

A Web 2.0 community-based site you are probably familiar with

http://www-949.ibm.com/software/rational/cafe/community/egl

Page 15: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

15© 2009 IBM Corporation

Web 2.0 and Rich Internet Applications – Enhanced User Experience

With Rich UI, your business applications can have the unmatched speed and usability of client side (browser-based) applications, while still being served and managed from centralized, dynamic content server applications: http://www.visualthesaurus.com/index.jsp

Additional examples include: http://www.adobe.com/resources/business/rich_internet_apps/examples/ http://www.visokio.com/demos/camerafinder http://www.smartmoney.com/map-of-the-market/

Page 16: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

16© 2009 IBM Corporation

Benefits of Web 2.0 – Modular Development and Component Reuse Because of the RBD tooling, programming-model and loose-coupling in the Because of the RBD tooling, programming-model and loose-coupling in the

EGL implementation of Rich UI – Software Reuse is not only easy:EGL implementation of Rich UI – Software Reuse is not only easy: EGL Rich UI application design tends towards reuse – as all interfaces are formally declared EGL Rich UI encourages functional decomposition:

From high-level (through differentiated file types) …to…low-level (“everything is a function that takes parameters”) – making it next to impossible to write in a monolithic programming style

Developers will choose reuse over re-write, as the tools and language accommodate this Software projects will benefit – as over time the R.O.I. for reuse will make it difficult to justify

writing “brand-spanking-new”

Rich UI Rich UI ApplicationApplication

ExistingExistingRUIHandlerRUIHandler

NewNewRUIHandlerRUIHandler

External RIAExternal RIAApplicationApplication

ExistingExistingWidgetWidget

RUIHandlerRUIHandlerElementsElements

ExistingExistingWidgetWidget

New New WidgetWidget

External External JavaScriptJavaScript

New and New and ExistingExisting

RUIWidgetsRUIWidgets

Page 17: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

17© 2009 IBM Corporation

What Web 2.0 Developers are Saying About EGL Rich UI EGL Rich UI is a really simple and powerful way to quickly implement a Web 2.0 application. Here are the main advantages:

No need to know Java, Java Script or HTML: everything can be written in pure EGL language. This language has a simple and clear syntax, independent from any other existing language and can be learnt in one or two weeks (may be a bit longer to be able to master the Rich UI-specific parts).

If needed, JavaScript and HTML can still be used to extend the EGL Rich UI features: for example, I wrote some JavaScript functions to manage character strings in a more complex manner than the basic EGL string library does. New JavaScript code has to be wrapped into an EGL object to be reused, which means that a JavaScript developer can write a whole new library of functions for an EGL developer who does not need to know anything about JavaScript.

Writing a Web 2.0 application is usually a daunting task, since you have to write HTML parts, manipulate a lot of JavaScript functions

to make them interact, and these parts are not managed as a whole: you have to cope with every little bit of HTML to make the application work. Instead, EGL Rich UI is all about working with components, or widgets, that you just have to assemble in a simple way to build an application, such as you would for a traditional client application (basically, you work with EGL Rich UI in the same manner as you work with Java Swing).

Each component can be graphically designed and tested, which is a lot faster than creating HTML code and testing it with JavaScript events. Each component can be reused without having to design it again: we use CSS stylesheets to define the style and presentation of a widget. Furthermore, the

newly created components can be integrated into the EGL Widgets palette so that other people can reuse them graphically into their own application. IBM provides its own basic EGL components from which more complex components can be built.

The components are totally independent: they communicate by an "InfoBus", which is a central component of an EGL Rich UI application. Widgets publish events to the InfoBus (e.g. a click on a button) and any other component in the application can subscribe to these events to retrieve and process them.

EGL Rich UI can easily be extended by wrapping Dojo or Silverlight AJAX objects into EGL objects: for example, this can be interesting to reuse already developed AJAX widgets that a customer would like to see in his new application

An MVC framework is provided in order to be able to quickly generate validating forms (which is the case in the Fulfillment application for the address asked to the customer when he wants to checkout)

An EGL Rich UI can easily interact and exchange data with other web applications: every needed feature is provided to access SOAP

or REST web services. Accessing a web service basically just consists in writing a line declaring the web service in a configuration file. From there, the web service can be accessed in EGL just as you would access a function in a local library.

Finally, an EGL Rich UI applications is just one full web page: there are no interactions between the server and the client, except when

calling web services. Every update in the GUI is done locally, whereas in traditional Web applications (Java/JSP, ASP.NET, ...) there are a lot of data exchanges. The server can then serve much more clients.

All these advantages together form a major improvement on how we can write Web 2.0 applications. I developed a number of components that we'll be able to reuse in future developments to drastically reduce development time.

Page 18: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

18© 2009 IBM Corporation

Web 2.0 – Section Review

Rich Internet Application technology is an element of (in fact, the enabler of the) Web 2.0 experience

RIA technology promises to raise the standard of internet use, providing customers with a more “human or interactive” experience, and including large-grain (new) functional capabilities such as:

Running software applications entirely on the browser

“Social networking” and web-”participation” – through interactive technologies such as “wikis” and collaborative forums

The ability to combine and merge content from diverse (client and server-side) sources (these are known as “mash-ups”)

For additional reading on Web 2.0, RIA and underlying languages and technologies – please visit these URLs: http://en.wikipedia.org/wiki/Web_2 http://en.wikipedia.org/wiki/Rich_Internet_application http://en.wikipedia.org/wiki/AJAX http://en.wikipedia.org/wiki/JavaScript http://en.wikipedia.org/wiki/Event-driven_programming http://www.quirksmode.org/dom/intro.html

Page 19: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

19© 2009 IBM Corporation

Course

Units:

Web 2.0 and Rich UIWeb 2.0 and Rich UI

EGL Rich UI – Terms and ConceptsEGL Rich UI – Terms and Concepts

Programming in EGL Rich UI

Learn EGL Rich UI

Appendix

Page 20: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

20© 2009 IBM Corporation

What is Rich UI?

Rich UIRich UI stands for RRich UUser IInterface. This is a phrase commonly used when talking about an interface that provides dynamic

rendering of its individual parts – notably, on the client-browser, as opposed to server-side processing

It is a technology that will allow developers of any background to create rich web pages like one would see on a leading-edge, Web 2.0 sites: www.digg.com www.hulu.com…others discussed in the previous section…

Rich Internet Application (RIA) – is often used synonymously with Rich UI

The benefits of Rich UI have a lot to do with Web 2.0 benefits, and include: Improved user-responsiveness

The most successful Rich UI implementations can achieve almost a “Windows-desktop” look and feel to users

“Rich-er” functionality – beyond the simple rendering of HTML, to include dynamic widgets and components

Improved browser/server load-balancing – as more of the business functionality can be distributed to the desktop (browsers)

Page 21: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

21© 2009 IBM Corporation

Rich UI and EGL

Rich UI leverages the generation capabilities of EGL to generate JavaScript JavaScript is a language that runs in a browser, (FireFox, Internet Explorer,

Opera, etc.) – not on the server like EGL-generated COBOL or Java

It is JavaScript that renders your page in the browser and manipulates labels, data, graphics and controls the page’s behavior No static HTML is created EGL generated JavaScript does all the work

Rich UI supports all the base EGL language constructs like libraries and records, while hiding the complexity of Web 2.0 functionality

Much of the U.I. is implemented using leading-edge internet technologies such as (all terms we will be defining shortly): AJAX DOJO JSON FLEX Web Services

Page 22: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

22© 2009 IBM Corporation

EGL: Shielding Complexity – Across the Development Lifecycle

ConsumeConsume Data + LogicData + Logic

UI UI ProduceProduce

JavaScriptJavaScriptAJAXAJAXDojoDojoGoogleGoogle

REST XMLREST XMLSOAP JSONSOAP JSON

SOAPSOAPXMLXMLRESTRESTPHPPHP

COBOLCOBOLJava RPGJava RPGSQLSQL

EGL EGL Widget Widget LibraryLibrary

IBM

Widget Writer

ISVs

Business Developers

Business Developers

EGL

Page 23: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

23© 2009 IBM Corporation

Rich UI Resources

On the EGL Café – in the EGL Rich UI hub: http://www-949.ibm.com/software/rational/cafe/community/egl/rui

…IBM is providing a wealth of: Examples Focused documentation Commentary Links

Page 24: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

24© 2009 IBM Corporation

Terms and Concepts – Rich UI and SOA

Rich UI makes extensive use of services, and SOAservices, and SOA – Service Oriented Architecture, which is a way to modularize and deploy code so that it can be consumed anywhere in the world using any language.

There are two types of Web Service calls used by Rich UI1.1. RESTful service callsRESTful service calls – A call made through the HTTP service-interface.

Once the call is made, a result is passed back to the requestor in XML or JSON format.

2.2. SOAP service callsSOAP service calls - A type of service call that is more popular in enterprise. It requires the exchange of XML messages between the client and host system.

By utilizing web services you build modular, scalable systems.

Server-SideServer-SideEnterpriseEnterpriseComputingComputing

AssetsAssets

EGLEGLServer-SideServer-SideApplicationApplicationResourcesResources

ServiceServiceCallsCalls

……and…and…ResultsResults

ServiceServiceCallsCalls

……and…and…ResultsResults

Rich UIRich UI

ApplicationApplicationJDBCJDBCCallsCalls……or…or…

ServicesServices

Page 25: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

25© 2009 IBM Corporation

More Terms and Concepts – AJAX, Widget, DOJO

AJAXAJAX – Stands for Asynchronous JavaScript and XML. Rich UI makes extensive (almost wholesale) use of AJAX, utilizing it whenever it makes a service call. Rich UI never executes a traditional HTML or .JSP page “Form Submit”.

WidgetWidget – A widget is a generic term for a graphical element in a GUI or Internet style interface. Most widgets allow for the interaction and manipulation of data in the browser.

DOJODOJO – An open source JavaScript toolkit. The DOJO project sets out to create widgets using only JavaScript. Rich UI is able to interface with DOJO code in order to pull in some of their widgets. http://dojotoolkit.org/

EGL WidgetEGL Widget

DOJO WidgetDOJO Widget

Page 26: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

26© 2009 IBM Corporation

Still More Terms and Concepts – JSON, Silverlight

JSONJSON – JavaScript Object Notation is lightweight format used by JavaScript to exchange data. JSON is able to serialize structured data, such as arrays, and exchange it among host and client machines.

SilverlightSilverlight – is a new technology developed by Microsoft that is similar to Macromedia’s Flash. Rich UI is able to interact with, and integrate with Silverlight widgets in your application:

Page 27: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

27© 2009 IBM Corporation

Cascading Style Sheet (.CSS file)Cascading Style Sheet (.CSS file)

Found under \WebContent\Found under \WebContent\

Classes inside of a Cascading Style Sheet

Classes inside of a Cascading Style Sheet

Widget Properties: classclassWidget Properties: classclass

A Cascading Style Sheet is a file composed of one to many “classes” which are labeled declarations of related HTML tags

A .css class is defined for a widget (like a TextLabel) in it class property .CSS tags are applied in the browser (at run-time) Cascading Style Sheets are used to make web pages U.I.:

Consistent Easy to develop Easy to maintain (a change definition propagates to all widgets that refer to the tag

Page 28: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

28© 2009 IBM Corporation

OPTIONAL Topic – The Internet 101OPTIONAL Topic – The Internet 101

Request/Response LifecycleRequest/Response Lifecycle: Uniform Resource Locator

Connect to a TCP/IP network: Through your ISP - internet Through an intranet/extranet

Enter a logical URL/URI address – press “GO” in the browser to make a request:

www.amazon.com

A global-database receives the request

And resolves the logical address into a physical address of a server that can respond to the request by either:

Serving a page Passing the request to an application

that can respond (dynamic data content web application)

If a dynamic content application, your EGL JSFHandler eventually gets control of the request (through a JSF framework), and processes it

And returns data (bound to JSF components) which end up processed by the JSF framework (Java) classes – which emits HTML and sends a response (reply) back to the user’s PC

Page 29: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

29© 2009 IBM Corporation

OPTIONAL Topic – OPTIONAL Topic – What’s in a URL (Uniform Resource Locator) Uniform Resource Locator (URL) is a technical, internet-term used as a synonym for Uniform

Resource Identifier (URI) – which is used by your browser to access and retrieve: Documents, Pages, Graphics…from a unique address of a network-based application or web server connected to the internet

Here is a sample URI dissected:

http://www.ibm.com “http://http://” tells the web browser to make a request on port 80 of type HTTP. “wwwwww” tells the browser to connect to a DNS (Domain Name Server) on the world wide web. Once connected to the DNS server, the hypertext, or “ibm.comibm.com” is resolved to an IP address. This IP

address is returned to the client browser which then makes a direct connection to the web server.

Here is a more interesting URI: http://localhost:5590/EGLRichUI/mysamples/ruiPropertySample.html?contextKey=5

• localhost:5590localhost:5590 = “this computer” listens on port 5590 (default for RUI development/Preview)

• /EGLRICHUI//EGLRICHUI/ = “the root directory of the application” - \WebContent\

• /mySamples//mySamples/ = “launch the RUIHandler named: ruiPropertySample.html – found in the \mySamples\ folder (directory) under \WebContent\

• contextKey=5contextKey=5 = “pass this RUIHandler the value 5, in a variable named: contextKey

Page 30: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

30© 2009 IBM Corporation

OPTIONAL Topic – the BrowserOPTIONAL Topic – the Browser

The browser (Internet Explorer, Firefox, Netscape, Mozilla, etc.).

Browser software: Understands and can

render HTML on the user’s PC

Understands and can execute the JavaScript generated by Rich UI – on the user’s machine (called “client/side”

processing)

Page 31: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

31© 2009 IBM Corporation

OPTIONAL Topic – Browser WarsOPTIONAL Topic – Browser Wars

There are documented operational and layout differences between the two most common browsers (IE and Firefox) – across:

o Basic U.I. properties (HTML rendering and tag references)o JavaScript interpretation

I.E. 6 Browser rendering

Page 32: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

32© 2009 IBM Corporation

Course

Units:

Rich UI – First StepsRich UI – First Steps

Create and Configure Rich UI projectCreate and Configure Rich UI project

The Rich UI Environment

Hello World

InitialUI and Children

Deep Dive into Box’s

Event Driven Development

Input Controls

Data Tables

Login Page

Calling a Service

Page 33: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

33© 2009 IBM Corporation

Create a new project Let’s start the tutorials by creating our very own EGL Rich UI project

Select File New Project

In the new project wizard, select EGL Project, and then click Next

Page 34: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

34© 2009 IBM Corporation

Create a new project The wizard should then ask you to provide a name for your project

Type (all one word) EGLRichUIEGLRichUI Next make sure to select Rich UI Project as your project type

Click FinishFinish The IDE will take a minute or two to create your project and set up the environment in your

workspace

Page 35: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

35© 2009 IBM Corporation

The Rich UI Environment Your workspace should now look as

follows: The default Rich UI project was created

along with your new project. Your newly created Rich UI project

The com.ibm.egl.rui_1.0.0 is essentially the core of RUI. This project contains: RUIWidgetRUIWidget definitions (more on these

later) Core language functionality

EGL Data Types Service Call API’s A Publish/Subscribe Framework called the

“InfoBus” A Framework for working with standard

data and event management, known as: MVC

Event handling logic

Page 36: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

36© 2009 IBM Corporation

Import a Custom Widget Project We will be using a # of custom widgets in this training course. These custom widgets comprise

learning examples and reusable components for your follow on Rich UI applications. You will need to import them from your setup folder on the desktop.

Steps: File (menu) Import Other Project Interchange Select the widgets.zip file

you downloaded for this class

A new project will be added to your workspace

Page 37: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

37© 2009 IBM Corporation

Setup Your Workspace for Cross-Project Source ReferenceSetup Your Workspace for Cross-Project Source Reference

In order for your Rich UI project to reference source parts in other projects in your workspace, you will need to add your other projects to the EGL Build Path

Steps: From Project Explorer:

Right-click over EGLRichUI Select Properties

From Properties > EGL Build Path Check the boxes for:

– EGLWeb

– com.ibm.egl.education.widgets

Click OKClick OK

Page 38: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

38© 2009 IBM Corporation

Copy the Images Folder From the EGLWeb Project to the EGLRichUI ProjectCopy the Images Folder From the EGLWeb Project to the EGLRichUI Project

In order for your projects to access images in your project, you will want some graphics files. We’ll use the ones you have in your EGLWeb project.

But (for expediency’s sake) you’ll need to copy these into your EGLRichUI project:

Steps: From Project Explorer:

Open the EGLWeb project Expand \WebContent\ Select and Copy the entire \images\ sub-folder under \WebContent\

From your EGLRichUI folder Expand \WebContent\ Paste the \images\ sub-folder under \WebContent\

Page 39: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

39© 2009 IBM Corporation

Configure Preferences

You may have already done this, but from

Window > Preferences From GenerationGeneration

UN-check Deployment Descriptor

Note that optionally you could check (on): (on): LibraryLibrary ProgramProgram ServiceService

Click OKClick OK

Page 40: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

40© 2009 IBM Corporation

Developing in Rich UI Let’s learn a little about what it’s like to develop using EGL Rich UI

The workbench view you’ll be using is the EGL Rich UI Editor

The Rich UI Editor provides: DesignDesign, SourceSource, and PreviewPreview modes

These three view modes are organized as sub tabs in the EGL Rich UI Editor The Design tab is the visual editor for Rich UI The Source tab is where you will go to directly edit EGL Rich UI source code The Preview tab is essentially a browser. This is where you will go to see what you’re

pages will look like to your customers or users

These three views are where you will spend a large majority of your time as a Rich UI developer.

The views are organized inside the workbench in the EGL Rich UI perspective

Recall from your previous EGL learning, that a “perspective” organizes related workbench views along the lines of developer roles and/or tasks.

An annotated snapshot of the Rich UI perspective is shown on the next slide

Page 41: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

41© 2009 IBM Corporation

Rich UI Perspective Similar to Web Perspective – but with different workbench views related to Web 2.0 development

Content Area

Where you design your Web 2.0 applications

Code EGL Rich UI statements

Test (Preview) your work

Content Area

Where you design your Web 2.0 applications

Code EGL Rich UI statements

Test (Preview) your work

PalettePalette

Project ExplorerProject Explorer

Outline,Properties and Events

Views

Outline,Properties and Events

Views

Problems&

Generation ResultsViews

Problems&

Generation ResultsViews

Page 42: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

42© 2009 IBM Corporation

Rich UI Projects

RUI projects consist of three default packages: EGLSource, JavaScript, WebContent

Within each of these three packages there are: Sub-Packages – to organize your project, containing:

EGL source files and other source files:– Cascading Style Sheet files– Graphics (images)

A project .eglbld file A project .egldd file

EGL Rich UI project source file PartPart types can be: LibrariesLibraries externalTypesexternalTypes – which can be used to call native or external

JavaScript functionality HandlersHandlers

The EGL Part type used specifically for Rich UIUI programming – is an EGL HandlerHandler

EGL Rich UI HandlersHandlers come in two sub-type parts: RUIHandlerRUIHandler

What we’ll call aWhat we’ll call a “View” “View” in this coursein this course RUIHandler of sub-type RUIWidgetRUIHandler of sub-type RUIWidget

What we’ll refer to simply as aWhat we’ll refer to simply as a “Widget” “Widget”

Page 43: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

43© 2009 IBM Corporation

Course

Units:

Rich UI – First StepsRich UI – First Steps

The Rich UI Environment

Create a new project

Rich UI Programming FundamentalsRich UI Programming Fundamentals

Web Application Layout and Design

Event Driven Development

Input Controls

Data Tables

Login Page

Calling a Service

Page 44: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

44© 2009 IBM Corporation

RUIHandlers – aka “Views”

RUIHandlers are used to create Rich UI applications that are composed of one-to-many on-screen RUIWidgets. These widgets can be IBM-provided widgets, or custom widgets that you’ve created

Elementary WidgetElementary Widget (ex. textbox, button HTML, etc.) (ex. textbox, button HTML, etc.)ExternalType ExternalType (provides access to native JavaScript)(provides access to native JavaScript)……

Cascading Style Sheet Cascading Style Sheet (optional property)(optional property)

RUIHandler type RUIHandler…RUIHandler type RUIHandler…

initialUI initialUI (initial U.I. rendering in the browser)(initial U.I. rendering in the browser)

onConstructionFunction onConstructionFunction (initial EGL Function)(initial EGL Function)

Custom Widget Custom Widget – can embed reuse existing Widgets– can embed reuse existing WidgetsonConstructionFunctiononConstructionFunctionElementary WidgetElementary WidgetElementary WidgetElementary WidgetEGL Function…EGL Function…

Custom Widget Custom Widget – can embed reuse existing Widgets– can embed reuse existing WidgetsonConstructionFunctiononConstructionFunctionElementary WidgetElementary WidgetElementary WidgetElementary WidgetEGL Function…EGL Function…

EGL Rich UIEGL Rich UIElementsElements

EGL Function(s)EGL Function(s)……

RUIHandlers are referred to as “views” because they represent the visual or “view-able” elements of your Rich UI application

Page 45: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

45© 2009 IBM Corporation

RUIHandlers – Code-Level Example

From the above, note the following: initialUI=[Box]initialUI=[Box] this Box being a RUIWidget of type boxbox – that contains three additional RUIWidgets:

– TextLabel (which has some initial text)

– TextField– Button – which has an onClickonClick function that fires populateFields(…)populateFields(…)

onConstructionFunction = initializationonConstructionFunction = initialization (which in this case does nothing but could!) populateFields(…)populateFields(…) EGL function – which just initializes text in the TextField RUIWidget Additional properties:

backgroundColor, width, height, columns=1

Page 46: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

46© 2009 IBM Corporation

RUIHandler – Containing a RUIWidget of type GridGrid

From the above, note the following: initialUI=[grid]initialUI=[grid] – declares a gridgrid RUIWidget inside the RUIHandler This grid widget contains a number of properties, all of which contribute to its look and

feel: headerBehaviors margin data (the individual rows)

Page 47: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

47© 2009 IBM Corporation

Basics of Rich UI Programming – RUIWidgets

RUIHandlers contain one-to-many RUIWidgetsRUIWidgets RUIWidgets can be thought of, or categorized as:

Simple: TextLabel Box Button

Complex: mortgage Calculator a sort-able, select-able list of customers

IBM provided: see the palette list on the right

Custom: you create the widget

A “container” widget for organizing U.I. elements: Box Div Tab folder

A “content widget” – for data and labels, behaviors, etc. Most of the other widgets in the palette

Complex RUIWidgets typically consist of both container and content widgets

All U.I. elements in a RUIHandler are RUIWidgets Example: To put a basic input field onto a page, you will declare a variable of type TextField – either

using the Visual Editor, or coding it using Content Assist in the EGL editor.

lNameInputField TextField {text=“LastName”};lNameInputField TextField {text=“LastName”};

IBM providedIBM providedRUIWidgetsRUIWidgets

Page 48: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

48© 2009 IBM Corporation

Basics of Rich UI Programming – Custom Widgets

You can add your own Custom Widgets to the Palette Custom widgets often contain elementary widgets or other custom widgets

– which can contain other custom widgets, etc. Among other benefits, this allows you to reuse code, and to scale – or

grow the U.I. in response to requirements that increase in complexity over time

Note: Don’t worry too much about the syntax in this exampleNote: Don’t worry too much about the syntax in this example We’ll be covering all these language concepts in a bitWe’ll be covering all these language concepts in a bit

Note: Don’t worry too much about the syntax in this exampleNote: Don’t worry too much about the syntax in this example We’ll be covering all these language concepts in a bitWe’ll be covering all these language concepts in a bit

Page 49: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

49© 2009 IBM Corporation

RUIWidget Properties

In EGL Rich UI, RUIWidget propertiesproperties (specified within the {}{} following the variable declaration…a short list of which is shown here displayed through Content Assist)

…play a huge role in the look and feel and behavior of the Widget in your application

There are an extraordinary number of properties you can customize to enable your RUI application for whatever business and U.I. requirements come at you. In fact – it’s not much of a stretch to say that this (virtually) unlimited programmatic access to the underlying deep-dive mechanics of each widget:

1. Allows you to create “un-compromising U.I.” designs – with EGL

2. Is a major difference between Rich UI and JSF (which is a Java-based framework that “hides” some of the properties you may need access to)

Note that there are two categories of Widget properties:

1.1. U.I. propertiesU.I. properties – Widget layout and display

2.2. Event-handling propertiesEvent-handling properties – that respond to Widget run-time behavior in the browser

Browser Browser Event handling Event handling

PropertiesProperties

U.I. U.I. PropertiesProperties

RUIWidgetRUIWidget. . <property><property>RUIWidgetRUIWidget. . <property><property>

Page 50: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

50© 2009 IBM Corporation

RUIWidget Properties – EGL Coding Example

To specify a RUIWidget property or event is very simple: U.I. property exampleU.I. property example – Set the text value and background color of a TextField

widget inside of the initial EGL function of RUIWidget or RUIHandler:

Browser event property exampleBrowser event property example – After the user enters data in a field and tabs out, execute a function to validate the data value entered:

Just code: variableName.property = valuevariableName.property = value

Just code a reference to an EGL function

The function in the RUIHandler must be declared with an input Event as a parameter.

After that? It’s all stock EGL syntax

Page 51: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

51© 2009 IBM Corporation

Simple RUIHandler/Elementary Widget – Document – 100 Foot View

Is figuratively represented by…

Page 52: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

52© 2009 IBM Corporation

Simple RUIHandler/Elementary Widget – Code – 10 Foot View

//NOTE references to U.I. elements//NOTE references to U.I. elements

//NOTE references to myTopBox Box//NOTE references to myTopBox Box

//NOTE: container for myBox02, myBox03//NOTE: container for myBox02, myBox03

//NOTE: When clicked? Assign value//NOTE: When clicked? Assign value

//NOTE: Properties of U.I. field//NOTE: Properties of U.I. field

//NOTE: Properties – including what function to invoke: “onClick”//NOTE: Properties – including what function to invoke: “onClick”

myBox02myBox02

myTopBoxmyTopBox

myBox03myBox03

Page 53: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

53© 2009 IBM Corporation

RUIWidget Properties and the Visual EditorRUIWidget Properties and the Visual Editor

When you create a new RUIHandler with the Visual Editor you can specify properties in the Properties view.

The property values available depend on the kind of widget (i.e. A “Box” can have columns, A TextField can be “read only”, can have a custom font, fontSize, fontWeight, etc.)

Some properties apply to all widgets: ColorColor – for text color AlignmentAlignment – Right/Left/Center

Note that (none) defaults to the parent container’s alignment

backgroundColorbackgroundColor – for the widget’s “fill (background) color” idid – a unique identifier for the widget ClassClass – the .css file’s unique class tag

Note that in order to pick up custom .css tags, you will need to code:cssFile = “relative/fileSpec.fileName.css”cssFile = “relative/fileSpec.fileName.css” – as a property of the RUIHandler

Besides the major (common to all widget) properties, there are five additional categories of Widget properties available from the Visual Editor for widgets: Border – to change the widget’s border line size and style Spacing – to add pixels of space between widgets Position – to precisely (or relatively) place a control in the browser Appearance – to change the color – including transparency of a widget, and to modify the cursor styling Accessibility – to specify user tab-key order and work with different devices (for the

handicapped)

Page 54: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

54© 2009 IBM Corporation

Event-Driven Programming and Event Handling

Programming in Rich UI utilizes what is called event driven developmentevent driven development. Most run-time behavior is based on user-directed events that occur on a web page. Some of these events include:

onClick onChange onKeyDown onKeyUp onFocusGained onFocusLost onMouseMove

Every widget on a web page can have events defined for it Widgets can even have multiple events defined:

An input TextField can have both onMouseOver (for context sensitive help)… and onFocusLost (to validate data entry before moving to the next field)

You specify defined events through EGL code, and from the Visual Editor

At run-time (in the browser), widgets listen for specific user-events, which can trigger calls to your EGL functions. You code “responses” to these events inside the functions: Data validation Data access

The responses to the events are in the form of standard EGL functions that contain EGL business logic and procedural statements (to do the data validation, data access, etc.)

There are additional types of events you’ll learn about later in this course that are not programmatic, and not tied to user-browser interaction

- keyboard events

- mouse events

Page 55: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

55© 2009 IBM Corporation

Event Handling and the Rich UI “Event Record”

While the Web 2.0 event-driven programming model permits multiple events on any/every widget in a web page, in practice you will define specific event-handlers to trap specific events when they occur.

This means that: When an event occurs in the browser (A User clicks a button – which fires an

onClick event) If you have defined an EGL event-handler for that event And you have coded an EGL function for that event-handler The Rich UI framework automatically invokes the EGL function you specify to

handle the event you declare The framework also gives you access to an Event RecordEvent Record, which provides a number

of properties and values that can be used in your U.I. business logic To do things such as:

Detect which button was clicked: e.widget.id Set focus to a widget: e.widget.focus(); Change the x/y coordinates of the widget in the browser (used for run-time

Drag & Drop operations)

Clicking the Multiply button fires an onClick event in

the browser.

If you have an event-handler defined for onClick

the JavaScript code (generated from your EGL) tied to the onClick event is

automatically run in the browser

HTML + JavaScript

Page 56: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

56© 2009 IBM Corporation

How Can I See All These Events and My EGL Code? (Use the Debugger!)

The EGL Debugger works exactly the same for Rich UI as it does for batch EGL, and EGL/JSF functionality

Steps:

1. Set your break-points (in the EGL editor’s left-hand border):

2. From Project Explorer, Debug your EGL Rich UI Application

Page 57: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

57© 2009 IBM Corporation

EGL Rich UI DebuggingWhen you Debug a Rich UI Application.1. Your RUIHandler will open in an external browser 2. Upon a defined event, the EGL function declared as that event-handler will be

fired off and loaded in the Debugger for you to step-through

You will also get to see/Debug through the EGL Widget framework code (or you can Zoom through the

code, if you’re not interested)

Page 58: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

58© 2009 IBM Corporation

Basics of Rich UI Programming – ExternalTypes – access to JavaScript

Rich UI allows you to use (or reuse) existing native JavaScript functionality

Example – call a JavaScript function defined through an EGL ExternalType to “Google map” an address

Fires onClick event

Calls JavaScript function

Page 59: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

59© 2009 IBM Corporation

A Small Sample Rich UI Application

Let’s take a look at a sample application and see what it comprises:

The above application is designed using 3 box RUIWidgets The outer-most box has one row and one column.

outerBox Box {marginLeft = 45, children = [outerBox Box {marginLeft = 45, children = [ mainContent mainContent ] };] }; Inside of the outer box is an inner box with three rows and one column, the top row holds

the image, the second row holds another table, and the last row holds the login buttonmainContentmainContent BoxBox {columns = 1, backgroundColor = "#C3D9FF", width = 270, roundedCorners =

yes, ALIGN_CENTER = Box.ALIGN_CENTER, children = [ image, loginBoxloginBox, login ] }; Finally, inside of the middle row is another box holding the labels and fields

loginBoxloginBox BoxBox { columns = 2, paddingLeft = 100, marginTop = 20, width = 270, { columns = 2, paddingLeft = 100, marginTop = 20, width = 270, children = [userNameLabel, userNameField, passwordLabel, passwordField] };children = [userNameLabel, userNameField, passwordLabel, passwordField] };

Page 60: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

60© 2009 IBM Corporation

Basics of RUI Programming – Design-Time Flexibility

Web pages created with Rich UI are extremely flexible to build and maintain For example, by simply changing the order in which children are assigned, a web page can

be completely turned upside down On the previous slide, we showed that our mainContent VBox had children

[image, loginBox, login] Changing the order of our children can render the following

[loginBox, login, image]– Note that each child is an individual widget declared just like EGL variables somewhere else in the RUIHandler

So all it takes to create a widget is a simple variable declaration? Yes, and you can structure where they are displayed on the page through VBox’s and

HBox’s!

Page 61: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

61© 2009 IBM Corporation

How do you Invoke a Rich UI Application from a Browser or External Application?

A deployed RUI applications URL is:"http://<domainName>:<port>/<web project name>/<DeployedRUIHandlerName>.html

Where domain name, port, and web project name are the same as you would specify for a web page, or .JSP page being run on an application server.

To define the deployedRUIHandlerName value - this is the name of the 'Main View', which is really what you are deploying, and represents the root of your application

Example Rich UI application deployed to Tomcat:http://www.ibm.com:8080/EGLRichUI/myHelloWorld.html

Example Rich UI application being developed in RBD:http://localhost:5590/EGLRichUI/mysamples/ruiPropertySample.html?contextKey=5

Note that you can invoke an external browser from Preview

Page 62: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

62© 2009 IBM Corporation

Course

Units:

Rich UI – First StepsRich UI – First Steps

Rich UI Programming “101” WorkshopsRich UI Programming “101” Workshops

Creating packages and RUIHandlers

Hello World

The Visual Editor

Rich UI Widget Properties

Rich UI Widget Events

Page 63: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

63© 2009 IBM Corporation

Workshop Section Let’s learn about what it’s like to develop using EGL Rich UI

Exploring Rich UI via Sample Code Creating your own RUIHandlers and RUIWidgets from scratch

HelloWorld Visual Editor Workshops (learning to use the Rich UI tools)

– Standard mode editing– Split Screen– Experimenting with common widget functions– EGL Rich UI Debug

Additional Workshop– Calculator– Temperature Converter– Login

Page 64: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

64© 2009 IBM Corporation

Workshop – Exploring Rich UI Using Sample Code In this workshop, you will:

Create a new Package in your EGL Rich UI Project Create a new RUIHandler inside the Package Copy/Paste some sample code Preview the web application Customize some of the EGL Rich UI properties

Page 65: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

65© 2009 IBM Corporation

Workshop – Create mySamples PackageCreate mySamples Package So now that we’ve got a new project, let’s create our first EGL Rich UI page.

First we’ll create a package to house this simple application.

Right-click over EGLSource and select New EGL Package

In the wizard that pops up, name the Package: mySamples, and then click Finish

Page 66: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

66© 2009 IBM Corporation

Workshop – Create sample1 in mySamples PackageCreate sample1 in mySamples Package Now let’s create a RUIHandler in the package. Right-clickRight-click over the mySamples

package and select: NewNew > EGL Rich UI Handler

Name the EGL source file: sample1sample1

Page 67: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

67© 2009 IBM Corporation

Workshop – Replace sample1 “Boilerplate” codeReplace sample1 “Boilerplate” code From the slide ***Notes***Notes, copy and paste the RUIHandler code for sample1sample1 From the RBD SSourceource view: Select all of the boilerplate statements and replace them with the

slide notes code. Save (Ctrl/S)Save (Ctrl/S)

Page 68: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

68© 2009 IBM Corporation

Workshop – Test and Play with sample1Test and Play with sample1 Select the PPreviewreview mode – click the Button

Return to the SSourceource mode, and modify some of the EGL code. Return to PPreviewreview mode to test (to view) your work

Page 69: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

69© 2009 IBM Corporation

Workshop – Create Your First RUIHandler (From Scratch) In this workshop, you will:

Create another new Package in your EGL Rich UI Project Create a new RUIHandler inside the Package Use the Rich UI Visual Editor to do initial web application layout Customize some of the RUIHandler properties in EGL Preview the web application

Page 70: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

70© 2009 IBM Corporation

Hello World – Create Package Let’s create (from scratch) our first EGL Rich UI page – and learn about the Rich UI

Visual Editor in the process

First we’ll create another new package: Right-click over EGLSource and select New EGL Package

In the wizard that pops up, name the package helloworldhelloworld, and then click Finish

Page 71: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

71© 2009 IBM Corporation

Hello World – Create RUIHandler – 1 of 2 Your project should now look

as follows:

Now let’s create a new RUIHandler

Right-click over the helloworld package and select new EGL Rich UI Handler

Page 72: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

72© 2009 IBM Corporation

Hello World – Create RUIHandler – 2 of 2 In the wizard that pops up, name the handler HelloHello, and then click finish

Hello.egl should now be opened in the Content Area by the EGL Rich UI Editor Let’s take a tour of the Rich UI Editor!

You should initially be in the editor sub tab of the editor This is much like the visual editor used for JSF

Page 73: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

73© 2009 IBM Corporation

The Visual Editor - Palette Notice the palette on the right side of

the editor

Think of the palette as what you would see in a JSF environment. From the palette we will drag and drop widgets onto our page

New Concepts: The palette is built into the design editor

instead of existing as its own eclipse view.

You may think that the list of widgets in the palette is quite sparse. This is because Rich UI allows you to define your own custom widgets!! The Refresh palette button exists so that

newly created widgets can appear on the palette and later dragged onto a page.

Initially, only the RUIWidgets are shown in the palette.

Page 74: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

74© 2009 IBM Corporation

Rich UI Application Design – RUIWidget – Box

The concepts behind designing pages with Rich UI are similar to what you would see when designing pages with basic HTML. In essence, a designer can still think in terms of laying out HTML tables on a page.

The fundamental Rich UI widget is a Box. A Box is just an HTML Table (a container, used to hold other controls, text and data)

The first step in creating any type of web page is most often the creation of an HTML table to give the page some structure.

The first and notably the last step to adding a component onto a page, is through the use of the children or initialUI variable property.

The above code creates an HTML table, then adds the input field as its child. In a Box, all children are given a new column in the HTML table (so, each child will

be added to the right of the child before it). If you would like children to be added vertically, you will need to tell the box how

many columns you would like.

 

Page 75: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

75© 2009 IBM Corporation

Hello World – Add a Box RUIWidget A RUI Widget is essentially a definition of an HTML tag. There exists a RUI Widget for almost every HTML tag (table, h1, h2, etc.). However, if a RUI Widget is not available for a particular HTML tag, you can always

implement one yourself!

Now let’s get on with our Hello World page! We’ll be placing a TextLabel, TextField, and Button onto the page.

From the palette drag, a Box onto the page Click on the Box and drop it anywhere on the page The editor will turn green indicating the location the Box (HTML Table) will be dropped.

Page 76: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

76© 2009 IBM Corporation

Hello World – Box Widget Properties Once you drop the Box onto the page, you will be greeted with a pop-up asking what

you would like to name your variable of type Box At this juncture, let’s just take the default (more on this later)

You should now see the outline of a Box in the visual editor!

The next step is to adjust some of the properties for the Box (make sure the Box is selected)

In the bottom left corner of the IDE, notice the Properties view From there specify “2” for the columns property

Press Ctrl/S to save the page.

Page 77: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

77© 2009 IBM Corporation

Hello World – Add a TextLabel Widget to the Box Now is a good time to re-explain the columns property for the Box

By telling our Box that we only want it to have 2 columns, we are limiting the table to having only 2 columns. As we put widgets inside of the Box, every 3rd widget will cause a new row to be created in the Box, and will be inserted into that row.

Let’s add a TextLabel to the Box From the palette, drag a TextLabel widget into the Box

Page 78: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

78© 2009 IBM Corporation

Hello World – TextLabel Widget Properties When you have dropped the TextLabel into the Box, name it myFirstTextLabel in

the pop-up that greets you.

The TextLabel should now be placed inside of the Box

With the label selected in the visual editor, focus on the Properties View and change the text to be “Hello World: ”, then press Enter

Page 79: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

79© 2009 IBM Corporation

Hello World – Add a TextField to the Box Next, drag a TextField onto the page, and inside of the Box

Once you’ve dropped the TextField into the Box, name it’s corresponding variable myFirstTextField

Page 80: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

80© 2009 IBM Corporation

Hello World – Add a Button to the Box Finally, let’s drag a button onto the page!

Remember that even though the visual editor may show the green bar as being to the right of the TextField, we specified that the Box has only two columns This will cause the button to actually be placed into the first column of a new row

When asked to give the Button a variable name, simply take the default by clicking OK

Your page should now look as follows!

Page 81: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

81© 2009 IBM Corporation

Hello World – Add an onClick Event to the Button With the newly created Button selected on the page, turn your attention to the

Properties view. Select the Events tab Click on the onClick event Click Add Event Handler Name the function populateTextField

Next, go back to the Rich UI EditorRich UI Editor and at the bottom of the view, switch to the Source ViewSource View

Page 82: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

82© 2009 IBM Corporation

Hello World – EGL Code (Source) View You should now see the code for the page

You should see three variables: a Button, a TextField, a TextLabel, and a Box

Inside of the function on the page, code the following line of EGL Source Remember to use Content Assist!

More on event handling later!

Page 83: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

83© 2009 IBM Corporation

Hello World – Preview (Run Hello World) What did we just do?

First, we created an event handler that would fire whenever the button was clicked Second, inside of this event handler, we set the text property of our input field to a literal

string

We are done with our first web application Switch to the Preview tab of the EGL Rich UI Editor

Notice the page finally running in a real browser

Click the button and see what happens

Page 84: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

84© 2009 IBM Corporation

Rich UI Box - Examples

Let’s take a look at the code for the HelloWorld page we just created!

Notice that we are using the columns = 2columns = 2 property

This means that every 3rd child will go on it’s own row in the table

Page 85: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

85© 2009 IBM Corporation

Rich UI Boxes

In the code, change the columnscolumns property to equal 1

Now return to the PreviewPreview tab of the EGL Rich UI Editor and notice the change in the page when it renders

Page 86: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

86© 2009 IBM Corporation

Workshop – Split Screen Editing, Widget Functions, Rich UI Debug In this workshop, you will:

Create another new Package in your EGL Rich UI Project Create a new RUIHandler inside the Package Use the Rich UI Visual Editor to do initial web application layout Use the Rich UI Editor in Split-Screen mode Use some of the common widget functions******

Widget.Fadein()Widget.Fadein() Widget.Focus()Widget.Focus() Widget.select()Widget.select() Widget.reSize()Widget.reSize()

Use the EGL Rich UI Debug facility Preview the web application

*** *** These functions are common to all widgets and widget types

Page 87: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

87© 2009 IBM Corporation

Create the Package and RUIHandler First, right-click over the EGLSource folder and create a new package

Name it sandboxsandbox

Next, right click over the sandbox package and create a new EGL Rich UI Handler

Name it: wksp2wksp2

Page 88: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

88© 2009 IBM Corporation

Add a Box and some Widgets to wksp2Add a Box and some Widgets to wksp2

Using the Visual Editor, add the following widgets to wksp2wksp2 boxbox

Name: boxOuterboxOuter columns: 22 alignment: CENTERCENTER backgroundColor: AliceBlueAliceBlue width: 400400 height: 300300

Four TextFields TextFields Named: TextField1 TextField1 TextField4 TextField4

Add a 2nd box and a Button inside the box Keep all of the defaults for both widgets Keep all of the defaults for both widgets

Page 89: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

89© 2009 IBM Corporation

Add an Event and an EGL Event-Handling FunctionAdd an Event and an EGL Event-Handling Function

Using the Visual Editor: Select the ButtonSelect the Button

From the Events sub-tab Click: Add Event HandlerAdd Event Handler Name the event: buttonClickEventbuttonClickEvent

From the onClickonClick Event Open the Function comboBox Select: buttonClickEventSelect: buttonClickEvent

Switch to EGL SourceSource editing mode Using Content Assist (Ctrl+SpacebarCtrl+Spacebar) add the following code in the buttonClickEvent(…)buttonClickEvent(…)

function:

Save your code

Page 90: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

90© 2009 IBM Corporation

Preview the View – Add Some New FunctionsPreview the View – Add Some New Functions

From Preview Click the button Note that the text is truncated in the widget’s U.I.

(let’s fix this)

From Source editing mode, add the following additional EGL statements to the RUIHandler:(again, use Content Assist to create)

Save, and from Preview, Click the button – note the effects of the new functions

Experiment with different values for the fadein/fadeout, width and select/focus functions

Page 91: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

91© 2009 IBM Corporation

Debug Rich UI Logic*** (See Slide Notes before beginning this Workshop)Debug Rich UI Logic*** (See Slide Notes before beginning this Workshop)

Recall from your previous EGL learning that to Debug you: Set breakpoints at the lines in the EGL source you wish to begin line-by-

line debugging By Double-clicking in the gray border

next to an operational line(not a declaration) – an executable statement

You Debug from Project Explorer

So go ahead!

From within wksp.egl - Set a breakpoint in the buttonClickEvent

From Project Explorer: - Right-click over wksp2.egl - Debug EGL Rich UI Application

Page 92: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

92© 2009 IBM Corporation

Debug Rich UI Logic – Test Your Rich UI LogicDebug Rich UI Logic – Test Your Rich UI Logic

Note that Debug will launch your view in the browser Enter values in some of the TextFields Click the button (and confirm the Perspective switch)

Besides viewing the code execution line by line, be sure to explore all of the widget properties and their values.

When finished?

Terminate and closethe Debugger.

Then return to the Rich UI Perspective

Page 93: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

93© 2009 IBM Corporation

Split Screen Mode in the Workbench – 1 of 3*** Slide NotesSplit Screen Mode in the Workbench – 1 of 3*** Slide Notes

One very nice way to understand the “cause and effect” between editing EGL code and using the Visual Editor to design your Rich UI applications is to work in split screen mode. To do this: With wksp2.egl already opened in the EGL Rich UI editor From Project Explorer:

Right-click over wksp2.egl Open with EGL Editor

With both editors open in the Content Area: Select the EGL Editor copy of the source Left-Click the tab (as shown) Hold and drag towards the bottom When the folder-pointer becomes a

downward-pointer release the mouse

Page 94: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

94© 2009 IBM Corporation

Split Screen Mode in the Workbench – 2 of 3Split Screen Mode in the Workbench – 2 of 3

So now you can: Use the Visual Editor

Drag & Drop Widgets from the Palette

Set Properties Move with mouse-based

development And see the new EGL

statements and properties in the code

…or you can …

Develop your Rich UI application from the EGL code-level And immediately see the

effect of your work in the Visual Editor

Let’s experiment with this a little (next slide)

Page 95: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

95© 2009 IBM Corporation

Edit in Split Screen Mode – 3 of 3Edit in Split Screen Mode – 3 of 3

From the Visual Editor, add a new Button to the RUIHandler (take all of the defaults)

Note the effect in the EGL source code (a new Button variable is added) Make some changes to the view by editing the EGL source and note the Visual Editor effect

PreviewPreview

In order to synch-up the source

copies in both editors you will have to save changes (on either side of the split-screen)

Page 96: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

96© 2009 IBM Corporation

Additional OptionalAdditional Optional Workshop – an Online Calculator

In this workshop, you will: Review Rich UI Events Create another new Package in your EGL Rich UI Project Create a new RUIHandler inside the Package Use the Rich UI Visual Editor to do initial web application layout Customize some of the RUIHandler properties in EGL Add event-handling functions in the RUIHandler that Preview the web application and test your work Optionally

Create additional calculator buttons and functions in the RUIHandler for subtraction, multiplication, division, etc.

Debug your calculator as an EGL Rich UI Application

Page 97: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

97© 2009 IBM Corporation

Create the Calculator’s Package and RUIHandler First, right-click over the EGLSource folder and create a new package

Name it calculator

Next, right click over the calculator package and create a new EGL Rich UI Handler

Name it: CalcCalc

Page 98: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

98© 2009 IBM Corporation

Add a Box to the Calculator, Editing in EGL Source Mode Let’s switch gears on this workshop, instead of using the visual editor, let’s code our

presentation logic using EGL source code editor. Once the Calc RUI Handler is opened in the EGL Rich UI Editor, switch to the Source mode

Now, let’s create an HTML table to lay out our UI Components: Code a new BoxBox (like below), and give it the property shown in the screen capture.

Remember to use Content Assist when specifying a type of widget or widget properties!

{ columns = 2 };{ columns = 2 }; Once the Box is created, add it to the initialUI property of the RUIHandler

This will ensure that onLoad, the table is rendered in the page.

Page 99: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

99© 2009 IBM Corporation

Add labels and fields to the calculator Add (code) labels and field widgets, then add them to the Box via the children=children=

property

Once the labels and fields are coded, add them to the Box as children. The web application should Preview similar to

Page 100: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

100© 2009 IBM Corporation

Add a RUIWidget Button Now that we have our UI Components on the page, we’ll add a Button to trigger an

event when the user clicks it, in the browser. Create a new Button in the RUIHandler source code below the resultValue variable

Next add the Button as a child to the Box

The web application should now preview as follows

Now let’s add an event listener to the button

Page 101: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

101© 2009 IBM Corporation

Add an onClick Event Listener to the Button Add a comma after the text property of the calcButton variable.

Press Ctrl+Spacebar Press Ctrl+Spacebar (Content Assist) Select the onClick-ButtononClick-Button event.

From there we will give the onClick event a function name: addValuesaddValues Initially you will see an error because the addValues function does not exist.

Next, code the following function below the calcButton variable (use Content Assist) Press Ctrl + Shift + O to bring in the import statement for Event

Page 102: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

102© 2009 IBM Corporation

Calculator – in Preview Note that all of the data in a web application is eventually of type stringstring For this reason we must cast the values in the input fields to int before we do math

Save the RUIHandler and try it out!

You have now been introduced to coding with Event driven development.

Re-examine the RUIHandler if you don’t understand what we just did For sure production applications will be more complicated than this

Note that as event listeners as you want can be applied to Widgets A widget could have an onClick property as well as onMouseOver and so on…

Page 103: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

103© 2009 IBM Corporation

Calculator – Optional Labs and Workshops If time permits, add three additional buttons to

the web application, bound to three functions for: Subtraction Multiplication Division

You may want to work with other styling elements as you’ve learned in these sections: Background color for your Calc widget backgroundColorbackgroundColor – or just colorcolor (which is text color) for

your resultValueresultValue

Also, if time permits:Also, if time permits: From the EGL Source Code Editor – add several From the EGL Source Code Editor – add several

break-points inside your Calculator functionsbreak-points inside your Calculator functions From Project Explorer: Debug your workFrom Project Explorer: Debug your work

Page 104: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

104© 2009 IBM Corporation

Optional Workshop – Simple Login Page Now that we’ve got a very nice Web 2.0 Calculator, let’s make a login page.

First right-click over the EGLSource folder and select New Package Name the package authenticate

Next right-click over the authenticate package and create a new Rich UI Handler.

Name the file: loginlogin

Page 105: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

105© 2009 IBM Corporation

Login Page Drag a box onto the page from the visual editor

Just take the default for the variable name.

Next add the following properties to the box using the visual editor

Page 106: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

106© 2009 IBM Corporation

Login Page Now that we’ve got a Box to lay out our

components, let’s go ahead and create some components to allow for username and password input!

Once the following components have been created, modify the Box declaration accordingly!

Save the page and compare your results to the following

Now that we have our UI laid out, let’s create some presentation logic that will authenticate a user and switch to the Calc view (continued on the next slide)

Page 107: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

107© 2009 IBM Corporation

Login Page Modify Calc.egl:

From Calc.egl (the source is in the \calculator\ package: Add a boxbox widget variable, named: layoutBoxlayoutBox (columns=2, etc. for properties)

– Also, put all of the current calculator widgets inside of layoutBox’s children=[…]children=[…] property

Code the following logic in the RUIHandler Note we are giving the RUIHandler two different events to listen for.

loginFunc (bound to the button) and resetUI (which you will bind to onFocusLost for the Password field)

Also note that we are creating a variable of type Calc and setting it as the child to our login box

Remember to press Ctrl + Shift + O to bring in import statements Bind the resetUI function to the onFocusLost event for the PasswordPassword field Save the file and Preview the web application (and test your coding)

Note that this technique assumes the main box in Calc is named: layoutBoxlayoutBox

Page 108: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

108© 2009 IBM Corporation

Additional Simple OPTIONALAdditional Simple OPTIONAL Workshop – an Online Temperature Converter

In this workshop, you will: Create another new Package in your EGL Rich UI Project Create a new RUIHandler inside the Package Use the Rich UI Visual Editor to do initial web application layout Customize some of the RUIHandler properties in EGL Add event-handling functions in the RUIHandler that Preview the web application and test your work Optionally add a function that converts Celsius to Fahrenheit and revise the U.I. accordingly

Page 109: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

109© 2009 IBM Corporation

Temperature Converter “High-Level” Steps Now that you’ve created a number of RUIHandlers you should be able to recall the steps to

create a new RUIHandler from scratch (if not feel free to scroll back through these slides and revisit them). So perhaps it’s time to see what you can do with only the final objective – instead all the detail click-for-click instructions.

Create a simple Fahrenheit to Celsius conversion web application on your own

Use the visual editor - or manually code the EGL presentation logic Whichever you feel more comfortable with

You could GOOGLE the algebra for the temp-conversion, but we’ll be generous, and give that to you

Page 110: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

110© 2009 IBM Corporation

Temperature Converter - Enhancements If time permits, you can upgrade the Converter to convert both from Fahrenheit to Celsius and

vice versa.

Here’s the new formula

You will need to modify a number of places in the RUIHandler source code.

You could either work on this yourself, or use the code in the ***Notes***Notes section of this slide as a model

Page 111: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

111© 2009 IBM Corporation

Course

Units:

RBD/EGL DevelopmentRBD/EGL Development

Rich UI Properties and Event HandlingRich UI Properties and Event Handling

Page 112: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

112© 2009 IBM Corporation

Working With RUIWidget Properties and Events In this comprehensive workshop, you will:

Create a new RUIHandler inside the mySamplesmySamples package Use the Rich UI Visual Editor to do initial web application layout Add several different types of RUIWidgets Work with (customize) the essential U.I. Properties and Events for the RUIWidgets

Using the Visual Editor Using EGL source code editing

Preview the web application – and verify “cause and effect”

Note – this is simply a learn by trial-and-error workshop, that asks that you experiment with different widget properties and events. Do not try too hard to match the PowerPoint screen captures exactly. And feel free to specify other settings for properties – just as long as you can tie the

eventual (Previewed) result with a specified property value

Page 113: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

113© 2009 IBM Corporation

RUIWidget Properties – Setting Basic Properties from the Visual EditorRUIWidget Properties – Setting Basic Properties from the Visual Editor

From your \mySamplesmySamples\ package, create a new RUIHandler named: ruiPropertySampleruiPropertySample

Using the Visual Editor, drag in a box – give the box the following properties: name: BoxBox Alignment: CENTERCENTER Columns: 22 Color: GrayGray BackgroundColor: WheatWheat Font: VerdanaVerdana fontSize: 10pt10pt fontWeight: boldbold

Using the Visual Editor, drag a TextLabel into the Boxdrag a TextLabel into the Box Name: TextLabelTextLabel

Preview Note the colors, alignment, font styling, etc.

Page 114: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

114© 2009 IBM Corporation

RUIWidget Properties – Modify Properties from the Visual EditorRUIWidget Properties – Modify Properties from the Visual Editor

From the PropertiesProperties view, modify the following for Box name: Box Box – Note you can not change the name from the Properties view

Alignment: LEFTLEFT Columns: 22 Color: MoccasinMoccasin BackgroundColor: SteelBlueSteelBlue Font: CourierCourier fontSize: 14pt14pt fontWeight: normalnormal

PreviewPreview

Customize the individual properties for the TextLabelTextLabel

Preview Note that the individual RUIWidget’s properties over-ride the Box

(container widget) properties, when both are set for the same attribute

Page 115: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

115© 2009 IBM Corporation

RUIWidget Properties – Set Border PropertiesRUIWidget Properties – Set Border Properties

From Properties, modify the Border values for Box borderColor: GoldenRodGoldenRod borderStyle: groovegroove borderWidth: 88

PreviewPreview

Customize the individual Border properties for the TextLabelTextLabel

PreviewPreview

Try a few different settings for border color and style PreviewPreview after each customization

Page 116: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

116© 2009 IBM Corporation

RUIWidget Properties – Set Padding PropertiesRUIWidget Properties – Set Padding Properties

Using the Visual Editor, drag in three additional TextLabels Be sure to add them inside of the Box

Preview (with Padding: 8 for the Box) From Properties, set the Box’s Padding to

2222 Preview

22 Preview

Set one of the TextLabel’s padding to: 2222 Preview

Padding adds space between the container (parent) component and its children

TextLabelwith padding: 22

Page 117: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

117© 2009 IBM Corporation

RUIWidget Properties – RUIWidget Properties – Set Position PropertiesSet Position Properties From PropertiesProperties, select

another TextLabelTextLabel, and set these Properties backgroundColor: GrayGray Position:

relativerelative X: 2222 Y: 3333 Width: 255255 Height: 4444

PreviewPreview

Change the same TextLabel’s positionposition to absoluteabsolute

Select, hold and drag the TextLabel inside the Box Drag the TextLabel

anywhere, the x/y will change accordingly

Preview … Preview … and press and press the Refresh buttonthe Refresh button

Relative positioning moves an element RELATIVE to its original position.

If you set x to -3 with relative positioning, the object moves 3 pixels to the left of where it would normally appear.

With absolute positioning, an element can be placed anywhere on a page by setting its x and y properties.

Relative positioning moves an element RELATIVE to its original position.

If you set x to -3 with relative positioning, the object moves 3 pixels to the left of where it would normally appear.

With absolute positioning, an element can be placed anywhere on a page by setting its x and y properties.

Page 118: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

118© 2009 IBM Corporation

RUIWidget Properties – Appearance PropertiesRUIWidget Properties – Appearance Properties

From Properties, select the TextLabel with the absolute position – and set the following Properties: Position:

X: 8X: 8 Y: 8Y: 8

Appearance Opacity: .6.6 Cursor: handhand

Opacity is a float ranged between 0 (zero, opaque) and 1.0 (one, completely transparent).

Select another TextLabel, and from Appearance, specify: Visibility:Visibility: hidden hidden

Select another TextLabel, and from Appearance specify: Cursor:Cursor: wait wait

Preview Preview

Note: 3D – effect with transparent (opaque) TextLabel in the foreground

http://www.w3.org/TR/css3-color/#transparency

Note also the hidden property … working

TextLabel with hidden property

Page 119: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

119© 2009 IBM Corporation

Course

Units:

RBD/EGL DevelopmentRBD/EGL Development

Cascading Style Sheets and Rich UICascading Style Sheets and Rich UI

Page 120: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

120© 2009 IBM Corporation

What is CSS?

It’s an axiom of the web development world that, CSS is very important in professional layout, consistency, and many aspects of U.I. So it should come as no surprise that the same is true for Rich UI and Web 2.0 development.

In recent years, free flow web designs have become the standard for all web pages. This means that HTML tables are no longer used for base UI layout. Instead, floating Divs are the preferred method.

These floating Divs are simply containers. Containers that are styled by CSS tags and classes.

By designing a web page with floating Divs and CSS, you end up getting a very flexible design. The entire look and feel of the web page can be changed by simply editing the CSS file, and never touching a single line of HTML. This one of the benefits of using CSS over HTML tables.

Page 121: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

121© 2009 IBM Corporation

CSS Syntax

Since this is a Rich UI specific course, we can’t teach the intricacies of – or deep-dive into CSS. We can however give quick overview – and teach you “about” CSS.

To start off, there are two types of CSS groupings: classes and IDs

A class can be referenced as many times as you want inside of an HTML file. An id, on the other hand, can only be referenced once – as it is also used by JavaScript

as the unique identifier for the Rich UI element it is assigned to(and can be returned by calling: document.getElementById(“…”) in native JavaScript

The two also have a slightly different syntax…see below

Note the differences in syntax between IDs and classes:

..<cssClassName> …instead of… ##<cssClassName>

Page 122: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

122© 2009 IBM Corporation

CSS – Workshop – 1 of 3

Lets now step into a simple but quick workshop that will demonstrate some of what you can do with CSS.

Create a new package under the EGLRichUI project called css.

Next, create a new Rich UI Handler called CSSDemo

Often pages are constructed with the following general layout and structure Container

Header Navigation Content

CSS is then used to position and style these elements

Each of the above elements are divs. Note that the content div may contain many more divs inside of it.

Page 123: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

123© 2009 IBM Corporation

CSS – Workshop – 2 of 3

Copy/Paste the following code in the notes, and replace the boiler plate code with it.

Note that we have created a standard layout using Divs.

A container has been created to hold all of the free form Divs. Inside of it is a header div, a nav div, and a content div. The content div in itself then contains several other divs Also note that we chose to use the CSS “id” property for things that would only appear on

the page once, and “class” property for things that could appear on the page multiple times!

Page 124: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

124© 2009 IBM Corporation

CSS – Workshop – 3 of 3

Now that we have created a simple layout using HTML (or in our case Rich UI), lets add the CSS to style it.

Copy/paste the code in the notes section of the slide and append it to the EGLRichUI.css file – which is under \WebContent\ in your EGLRichUI project

Note the use of two properties: Position: relativerelative Float: leftleft

These are the key properties for designing free flow web pages

Study the code, edit it, and examine the changes, then go to the following URL to learn more about CSS topics: http://www.w3schools.com/css/

Page 125: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

125© 2009 IBM Corporation

RUIWidget Properties – .CSS Classes – RUIWidget Properties – .CSS Classes – 1 of 31 of 3 As you’ve seen, U.I. characteristics can be

set manually – and explicitly and directly for each RUIWidget (and RUIWidget elements)

However, it’s likely that the look & feel of your application will be controlled by the entries in your .CSS (Cascading Style Sheet)

Your Rich UI project will have a Cascading Style (or more than one, it depends on your shop web standards) in the \\WebContent\css\WebContent\css\ directory. This file has to be in the \WebContent\

directory, but not necessarily under \css\ - that’s your call

A .css file contains two entities: classes – which begin with a period

See .outputTextSmallBoldRed.outputTextSmallBoldRed ids – which begin with a pound sign

See .boxStyle.boxStyle

The format of a .css class is as follows:• Period (or dot)• Unique className (unique within the file)• Open curly brace• A set of HTML properties as value pairs – ending with a semi-colon• A closing curly brace• A closing semi-colon

In order for your RUIHandler to use the classes In order for your RUIHandler to use the classes and ids within a .CSS file, you will add a property and ids within a .CSS file, you will add a property to the handler statement as follows:to the handler statement as follows:

cssFile=cssFile=“folder/CSSFileName.css”“folder/CSSFileName.css”

And you will reference the specific .CSS class And you will reference the specific .CSS class in the in the classclass property of your widget property of your widget

The format of a .css class is as follows:• Period (or dot)• Unique className (unique within the file)• Open curly brace• A set of HTML properties as value pairs – ending with a semi-colon• A closing curly brace• A closing semi-colon

In order for your RUIHandler to use the classes In order for your RUIHandler to use the classes and ids within a .CSS file, you will add a property and ids within a .CSS file, you will add a property to the handler statement as follows:to the handler statement as follows:

cssFile=cssFile=“folder/CSSFileName.css”“folder/CSSFileName.css”

And you will reference the specific .CSS class And you will reference the specific .CSS class in the in the classclass property of your widget property of your widget

Page 126: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

126© 2009 IBM Corporation

RUIWidget Properties – .CSS Classes – 2 of 3RUIWidget Properties – .CSS Classes – 2 of 3

From Project Explorer, open your project’s .css file and add a new class as shown Note that Content Assist (Ctrl+Spacebar) can

be used to help you build the entries shown here

Save the file and your changes

From the Visual Editor – with ruiPropertySampleruiPropertySample in the Content Area: Select the outer BoxBox (simply named “Box”)

and from Properties, erase the font property

Select one ore more of the TextLabelsTextLabels, and specify a class property as follows:

Note that .css class names Note that .css class names are cAsE SenSItivEare cAsE SenSItivE

Add the following .css class to your project’s .css file:

..outputTextSmallBoldRed outputTextSmallBoldRed {{font: font: VerdanaVerdana; ; font-size: font-size: 12pt12pt;;color: color: redred;;font-weight: font-weight: boldbold;;

};};

Add the following .css class to your project’s .css file:

..outputTextSmallBoldRed outputTextSmallBoldRed {{font: font: VerdanaVerdana; ; font-size: font-size: 12pt12pt;;color: color: redred;;font-weight: font-weight: boldbold;;

};};

Page 127: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

127© 2009 IBM Corporation

RUIWidget Properties – .CSS Classes – 3 of 3 – and Styling HierarchyRUIWidget Properties – .CSS Classes – 3 of 3 – and Styling Hierarchy From the EGL Editor (in Source mode)

In the In the handlerhandler statement, notice the property just after the open curly statement, notice the property just after the open curly brace: brace: cssFile = "css/EGLRichUI.css"cssFile = "css/EGLRichUI.css"

Preview Preview

Hierarchy of Style ElementsHierarchy of Style Elements

The run-time view will reflect your styling design elements as follows:

IndividualIndividualRUIHandlerRUIHandlerPropertiesProperties

.css Classes and IDs.css Classes and IDs

HTML element defaultsHTML element defaults

OrderOrderOfOf

PrecedencePrecedence

OrderOrderOfOf

PrecedencePrecedence

Page 128: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

128© 2009 IBM Corporation

Optional Lab - Optional Lab - RUIWidget Alignment Properties RUIWidget Alignment Properties

This is a simple, copy/paste RUIHandler that allows you to see how to use: Box Alignment Box Padding Dynamic Widget declarations (using new – inside the

code)

Steps: From the mySamplesmySamples package, create a new RUIHandler

named: AlignmentAlignment From the Slide ***Notes***Notes

Copy all of the codeCopy all of the code Completely replace the existing Completely replace the existing

RUIHandler boilerplate statementsRUIHandler boilerplate statements SaveSave

Preview Preview

Study the coding solution, and note Study the coding solution, and note cause & effectcause & effect

Page 129: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

129© 2009 IBM Corporation

“What was it about those browser events?” – Review

EGL Rich UI utilizes what is called event driven development. Much of the run-time behavior is based on user-directed events that occur on a web page. Some of these events include:

onClick onChange onKeyDown onKeyUp onFocusGained onFocusLost onMouseMove

Every widget or “thing” on a web page can have events tied to it.

At run-time (in the browser), widgets listen for specific user-events, which can trigger calls to your EGL functions. You code “responses” to these events inside the functions: Data validation Data access Etc.

Understanding the event driven development model is important – and it’s possibly quite different from the kind of software programming you have done before. We’ll dedicate a few extra slides to it…okay?

Page 130: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

130© 2009 IBM Corporation

Concepts – Event-Driven, Preemptive Programming Model

RUIwidgets (buttons, listboxes, textfields, etc.) respond to eventsevents that are: Event-DrivenEvent-Driven – They happen when they happen arbitrarily not as a result of:

Sequence, Selection and Repetition PreemptivePreemptive – events can (and will) fire off calls to EGL functions when they occur –

concurrently, but not “multi-threaded”

Terms and Concepts – Deep DiveTerms and Concepts – Deep Dive An eventevent is:

An external occurrence of some user action in the browserAn external occurrence of some user action in the browser (like a user mouse-click, or button-click, or ListBox selection, or mouse-over (“hover-help”), etc.

A non-visual occurrence of something like a return from a Service call or return from a call to an external JavaScript or some other RUIWidget

The EGL Functions that respond to events are called: event handlersevent handlers Events require an event dispatcherevent dispatcher to call your EGL event handlers (Functions)

In the Rich UI world, the event dispatcher is provided by the framework and system code (i.e. you don’t write such things – at least not in EGL)

Your development (EGL Rich UI logic) will thus largely consist of: Coding EGL statements inside of functions that respond to the various external and non-

visual events you wish to handle, so that the event dispatcher will know which ones to call: There are essentially two types of EGL Functions:

Initial U.I. presentation or “set-up code” – that is executed before the application A collection of EGL functions that respond to visual and non-visual events

Page 131: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

131© 2009 IBM Corporation

Concepts – Browser Events and Actions

In Rich UI, browser events are generated based on user input: Mouse clicks, mouse movement, mouse button release Key presses, Key releases Etc.

Each widget gets to define what constitutes an event for it, and which EGL Function will be associated with it: button.onClick listControl.onChange

Any given widget may allow multiple kinds of EGL Functions to be associated with its events: inputText.onKeyUp inputText.onFocusLost inputText.onChange

ExampleExample – in this Grid control, when the user “clicks” a row, the values in that row are loaded into the detail Widget above it in the browser.

ConverselyConversely – if the user modifies a value and clicks the Update button? The corresponding value in the Grid control is modified.

Page 132: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

132© 2009 IBM Corporation

RUI Programming FunctionalityEvent-Driven Programming Model

The event dispatcher (Remember? You don’t code this) calls your EGL Function when the appropriate combination of user inputs occurs at run-time.

This is based on your development specifications, which include: A defined event handler The EGL function code in your

RUIWidget / RUIHandler

Besides calling your event-handling EGL code, the event dispatcher also passes an event argumentargument to your code:

(e event inin) The argument contains details

about the event which you can use programmatically to solve dynamic U.I. requirements such as: Drag & Drop Determining which button was

clicked, etc.

Page 133: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

133© 2009 IBM Corporation

Comparison: Synchronous vs. Event-Driven Programming Models

SynchronousSynchronousTraditional Run-time modelTraditional Run-time model

(Next Sequential Instruction programming idiom)(Next Sequential Instruction programming idiom)

Do processingDo processing……

Call a service Call a service

Wait … Wait … Wait …Wait …Wait …Wait …Wait …Wait …

Service call returns! Service call returns! ……

Do more processingDo more processing……

Do processingDo processing……

Call a service Call a service (Specify a “Callback” Function)(Specify a “Callback” Function)

……

Do more processingDo more processing……

Service call returns! Service call returns! (“Callback” Function (“Callback” Function is automatically invoked)is automatically invoked)

……

Do more processingDo more processing

……

Event-DrivenEvent-DrivenRich UI Run-time modelRich UI Run-time model

(Modular, independent functions)(Modular, independent functions)

Page 134: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

134© 2009 IBM Corporation

Event Handlers/Event Dispatchers as an “Event Pipeline”

Do InitialProcessingDo InitialProcessing

Render RUI artifacts in browserRender RUI artifacts in browser

EventEvent - onClick - onClick captured incaptured in RUIHandler, handled RUIHandler, handled as an EGL Functionas an EGL Function

Call a serviceCall a service (note that calling a (note that calling a service does NOT pre-req. a service does NOT pre-req. a browser/user event)browser/user event)

EventEvent - Service call returnsService call returns

(EGL “Callback” Function (EGL “Callback” Function automatically invoked)automatically invoked)

User clicks a button

Events in the Events in the BrowserBrowser

RUI Handler (EGL) codeRUI Handler (EGL) code

DatabaseDatabase

Enterprise DataEnterprise Data

Control immediately returns to the browser

EventEventPipelinePipeline

Page 135: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

135© 2009 IBM Corporation

RUIWidget EventsRUIWidget Events

So now, let’s do some work with events and RUIWidgets. From the Palette, add two TextFields, add two TextFields, a Button and another TextLabel into the Boxa Button and another TextLabel into the Box

(Review/Practice) Customize some of the properties. Don’t try to replicate the screen capture exactly, just be sure you understand cause & effect for the properties when you Preview

Some Properties you might want to experiment with include: ColorColor BackgroundColorBackgroundColor WidthWidth FontFont FontSizeFontSize FontWeightFontWeight OpacityOpacity Border:Border:

ColorColor StyleStyle

PreviewPreview

Page 136: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

136© 2009 IBM Corporation

RUIWidget Events – onFocusLost/onFocusGainedRUIWidget Events – onFocusLost/onFocusGained

onFocusLostonFocusLost happens when a user tabs or clicks out ofout of a field onFocusGainedonFocusGained happens when a user tabs or clicks intointo a field

To understand how this works:To understand how this works: Add the following two functions to your Add the following two functions to your

RUIHandler’s source code RUIHandler’s source code SaveSave your code your code

From the Design view:From the Design view: Select TextField1Select TextField1, and from Properties/Events:

open the onFocusLost Function combo-boxopen the onFocusLost Function combo-box select focusLostFuncselect focusLostFunc

Select TextField2, Select TextField2, and from Properties/Events: open the onFocusGained Function combo-boxopen the onFocusGained Function combo-box select focusGainedFuncselect focusGainedFunc

PreviewPreview Type a value into TextField1 and hit the Tab key on your PC so that the FocusLost and FocusGained events fire off. Type a value into TextField1 and hit the Tab key on your PC so that the FocusLost and FocusGained events fire off.

You can also type into TextField1 and mouse-click into TextField2 You can also type into TextField1 and mouse-click into TextField2

Page 137: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

137© 2009 IBM Corporation

Back to Properties Back to Properties (for just one slide)

So – you probably noticed that when you tabbed out of TextField1 (at Preview time) the box So – you probably noticed that when you tabbed out of TextField1 (at Preview time) the box “tightened up” (resized itself) proportionately to the # of characters of content in your TextField.“tightened up” (resized itself) proportionately to the # of characters of content in your TextField.

My bet? This is not a behavior you want – at least not a default.My bet? This is not a behavior you want – at least not a default.

To make the boxes fixed-width - from the Design view:To make the boxes fixed-width - from the Design view: Select each of the TextFields (one at a time), and from Properties/PositionSelect each of the TextFields (one at a time), and from Properties/Position

Specify a fixed-width:Specify a fixed-width:

PreviewPreview

Page 138: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

138© 2009 IBM Corporation

RUIWidget Events – onClickRUIWidget Events – onClick

onClickonClick happens when a user clicks a Widget with their mouse – typically a button, radio-button, check-box, etc.

To see how this works:To see how this works: Add the following new functionAdd the following new function

to your RUIHandler’s source code:to your RUIHandler’s source code: SaveSave your code your code

From the Design view:From the Design view: Select the Button, and from Properties/Events, Select the Button, and from Properties/Events,

open the onClick Function combo-boxopen the onClick Function combo-box select buttonClickedFuncselect buttonClickedFunc

PreviewPreview Click the Submit ButtonClick the Submit Button Check out the text value of TextLabel2 TextLabel2

Page 139: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

139© 2009 IBM Corporation

RUIWidget Events – onMouseOver/onMouseOutRUIWidget Events – onMouseOver/onMouseOut onMouseOveronMouseOver happens when a user hovers their mouse over a widget. This is typically used

for: Context-sensitive (hover) help Rolling images over – i.e. making the images bigger, etc.

onMouseOutonMouseOut happens when a previously hovering mouse over a widget leaves the widget’s area

To see how this works:To see how this works: Add the following new functions to your Add the following new functions to your

RUIHandler’s source code:RUIHandler’s source code: Save your codeSave your code

From the Design view:From the Design view: Select one of the TextLabels, and from Select one of the TextLabels, and from

Properties/Events, Properties/Events, Select onMouseOut andSelect onMouseOut and……onMouseOver functionsonMouseOver functions

PreviewPreview Hover your mouse over the TextLabel … … then move your mouse away from the TextLabelHover your mouse over the TextLabel … … then move your mouse away from the TextLabel

Page 140: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

140© 2009 IBM Corporation

RUIWidget Events – onContextMenuRUIWidget Events – onContextMenu

onContextMenu onContextMenu happens when a user RIGHT-clicks over a Widget with their mouse

To see how this works:To see how this works: Add the following new function to your Add the following new function to your

RUIHandler’s source code:RUIHandler’s source code: Save your codeSave your code

From the Design view:From the Design view: Select TextField1, and from Properties/Events, Select TextField1, and from Properties/Events,

- open the onContextMenu Function combo-box- open the onContextMenu Function combo-box

- select onContextMenuFunc- select onContextMenuFunc

PreviewPreview First First Left-clickLeft-click over TextField1 over TextField1 (nothing, correct?) Then Then Right-clickRight-click over TextField1 over TextField1

Page 141: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

141© 2009 IBM Corporation

RUIWidget Events – EGL Rich UI Code-EventsRUIWidget Events – EGL Rich UI Code-Events

There is much more on Event Handling we’ll cover later in this section. For now, it is There is much more on Event Handling we’ll cover later in this section. For now, it is enough to understand that:enough to understand that: All of the events you just specified through the Visual Editor tooling may be specified in EGL There are other events you have access to – available as:

Properties of the widgetsProperties of the widgets Properties of the Event Record (which is passed in to each function as an input parameter)Properties of the Event Record (which is passed in to each function as an input parameter)

To see how this works:To see how this works: Modify the buttonClickedFunc()Modify the buttonClickedFunc()

……… ……… as shown here as shown here

Add the following new function to your Add the following new function to your

RUIHandler’s source code RUIHandler’s source code Save your codeSave your code

PreviewPreview and click the button. and click the button. Note the effect of the U.I. programming techniques Note the effect of the U.I. programming techniques on: TextField2 (selection, setting focus, dynamic width), and on the Buttonon: TextField2 (selection, setting focus, dynamic width), and on the Button

From the From the HelpHelp system, search on: system, search on: fadeinfadein

Page 142: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

142© 2009 IBM Corporation

RUIWidget Events – onKeyPress/onKeyUp/onKeyDownRUIWidget Events – onKeyPress/onKeyUp/onKeyDown The onKeyxxx events happen as a user types into a control (typically an input field). These events are

commonly used for: Trapping (determining) which key was pressed Trapping (determining) which key was pressed – and subsequently doing something meaningful based on this Doing Letter-by-Letter data entry processingDoing Letter-by-Letter data entry processing – example: firing off database access reads as each letter of some code

is typed in to the browser)

To see how this works:To see how this works: Add the following new function to your Add the following new function to your

RUIHandler’s source code RUIHandler’s source code Note – these two functions are in theNote – these two functions are in the

***Notes section of this slide***Notes section of this slide Save your codeSave your code

From the Design view:From the Design view: Select TextField1, and from Select TextField1, and from

Properties/Events, Properties/Events, Select onKeyUp andSelect onKeyUp and……onKeyUpFunconKeyUpFunc

Select TextField2, and from Select TextField2, and from Properties/Events, Properties/Events,

Select onKeyDown andSelect onKeyDown and……onKeyDownFunconKeyDownFunc

PreviewPreview Type values into TextField1Type values into TextField1 Press a function key over/into TextField2Press a function key over/into TextField2

Page 143: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

143© 2009 IBM Corporation

Open-ended Workshop – Registration Page In this workshop, you will:

Create another new Package in your EGL Rich UI Project Create a new RUIHandler inside the Package Use the Rich UI Visual Editor to do initial web application layout Customize some of the RUIHandler properties in EGL Add event-handling functions in the RUIHandler that Preview the web application and test your work Optionally add additional calculator buttons and functions in the RUIHandler

Page 144: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

144© 2009 IBM Corporation

Events - SummaryEvents - Summary

onChange onChange onChange occurs when the user changes a widget and moves the on-screen focus from that widget, even if the user has reversed the change.

onClick onClick onClick occurs when the user clicks on the widget.

onFocusGained onFocusGained onFocusGained occurs when the widget gains the focus.

onFocusLostonFocusLost onFocusLost occurs when the widget loses the focus. The equivalent event in JavaScript is onBlur

onKeyDown onKeyDown onKeyUp onKeyPressonKeyUp onKeyPress

On many browsers, the event occurs repeatedly for as long as the user is pressing the key. Each occurrence of onKeyDown is followed by an occurrence of onKeyPress.

onMouseDown onMouseDown onMouseDown occurs when the user presses any mouse button.

onMouseMove onMouseMove onMouseMove occurs repeatedly when the user moves the mouse while the on-screen cursor is within the boundary of the widget.

onMouseOver onMouseOver onMouseOver is an event that JavaScript could have named onMouseIn. The event occurs when the user moves the mouse, just as the on-screen cursor moves into the widget. You can use this event, for example, to change the cursor symbol for a particular part of the page.

onMouseInonMouseIn The event occurs when the user moves the mouse, just as the on-screen cursor moves into the widget. You can use this event, for example, to change the cursor symbol for a particular part of the page.

onSelect onSelect onSelect occurs when text is selected in a textArea or textField widget.

onMouseUp onMouseUp onMouseUp occurs when the user (having pressed a mouse button) releases it.

Page 145: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

145© 2009 IBM Corporation

Course

Units:

Rich UI Widgets – Deep Rich UI Widgets – Deep DiveDive

Rich UI Programming Widget WorkshopsRich UI Programming Widget Workshops

Text Widgets

Selection Widgets

Container Widgets

HTML Widgets

IBM-Supplied Widgets

Dojo Widgets

Page 146: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

146© 2009 IBM Corporation

Rich UI Widgets

There are a number of EGL Widgets supplied by: IBM 33rdrd Party Vendors Party Vendors (i.e. Dojo Widgets) YouYou (Custom Widgets)

In this section, we’ll deep-dive on all of the EGL widgets in the Palette: Their essential properties – beyond the properties we’ve just finished

studying Standard (common) events – ditto

We’ll categorize the widgets into: EGL Widgets:

Text Widgets Selection Widgets Container Widgets Miscellaneous EGL Widgets

HTML Widgets Other IBM-supplied Widgets Dojo Widgets

For each group we’ll: Create a custom RUIHandler Work with the properties and events

Page 147: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

147© 2009 IBM Corporation

Course

Units:

Rich UI WidgetsRich UI Widgets

Text WidgetsText Widgets

Selection Widgets

Container Widgets and View Layout

HTML Widgets

IBM Widgets

Page 148: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

148© 2009 IBM Corporation

Workshop – Work With Rich UI Text Widgets In this workshop, you will:

Create a new RUIHandler inside the mySamplesmySamples package Use the Rich UI Visual Editor to do initial web application layout Add several different types of Rich UI Text Widgets:

TextLabel TextField TextArea PassWordTextFeld

Work with (customize) the essential U.I. Properties and Events for the RUIWidgets Using the Visual Editor Using EGL source code editing

Preview the web application – and verify “cause and effect”

Note – this is simply a learn by trial-and-error workshop, that asks that you experiment with different widget properties and events. Do not try too hard to match the PowerPoint screen captures exactly. And feel free to specify (experiment with) other settings for properties – just as long as:

You can tie the eventual (Previewed) result with a specified property value Time permits

Page 149: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

149© 2009 IBM Corporation

Rich UI Text Widgets

The text widgets are used for input/output text values. There are four of them: TextLabelTextLabel – output (read-only) text TextField TextField – input or input/output text TextAreaTextArea – input or input/output text in a scroll-able box (area) PassWordTextFieldPassWordTextField – input text displaying asterisks for security

Workshop: Create a new RUIHandler in: \mySamples\\mySamples\ - named: textFieldstextFields Add a 1-column Box1-column Box Into Into (inside) the Box the Box, add the following EGL Widgets

TextLabelTextLabel TextFieldTextField TextAreaTextArea PassWordTextFieldPassWordTextField

Take all of the defaults for Properties for the Widget names Add Text to match the Widget names

PreviewPreview

Page 150: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

150© 2009 IBM Corporation

TextLabel Widgets – Common Properties and Events

Add the following common TextLabel tags to a new class in EGLRichUI.css: font-family: Verdana; font-size: 10pt; color: red; font-weight: bold; text-align: right; width: 123;

Assign this .css class to the TextLabel

Add the following line to the textFieldstextFields handlerhandler statement for cssFilecssFile:

Preview:

Feel free to experiment with other properties and/or events that you’ve already learned about: Border BackGroundColor, etc.

Page 151: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

151© 2009 IBM Corporation

TextField Widgets – Common Properties and Events

Add the following common TextField tags to new classes in EGLRichUI.css: Code for the .css entries is in the ***Notes section of this slide

Add the following function to your RUIHandler

Assign this .css class to the TextField:

Bind the validateText function to the onFocusLost event:

Preview Type values in the field Tab – or click out of the field Note the U.I. behavior

Feel free to experiment with other properties and/or events that you’ve already learned: Border Font Color BackGroundColor, etc.

Page 152: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

152© 2009 IBM Corporation

TextArea Widgets – Common Properties and Events

Add the following common TextArea tags to a new class in EGLRichUI.css:

Add the following function to your RUIHandler

Add the following assignment statement to your RUIHandler’s initialization() function

Assign this .css class to the TextArea:

Bind the processTextArea function to the onFocusLost event:

Preview Type values in the TextArea Tab – or click out of the field Note the U.I. behavior

Feel free to experiment with other properties and/or events that you’ve already learned

Page 153: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

153© 2009 IBM Corporation

Add the following two new variables, and modify your RUIHandler’s initialization() function Use Content Assist!Use Content Assist!

Add the following function to your RUIHandler Code is in the

slide ***Notes***Notes

Bind the validatePassWord function to the onFocusLost event:

Preview and testPreview and test both the login functionality and tooltip (mouse-over). There is one bug you might want to clean up (can you find it? It’s a U.I. bug) and you might want to add a button that fires off the validatePassWord function, rather than having it occur onFocusLost

TextPassWord Widgets – Common Properties and Events

Page 154: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

154© 2009 IBM Corporation

EGL Rich UI allows you accessibility to the entire HTML syntax range, for input text fields (actually for all HTML tags) through the setAttribute(xxx,yyy)setAttribute(xxx,yyy) function.

You could use this to do things like: Dynamically modify TextField UI characteristics Add in any currently un-supported tooling features, such as:

maxLengthmaxLength Learn more about HTML input attributes: http://www.htmlcodetutorial.com/forms/_INPUT.html

Workshop: Add the following

code to textFieldstextFields:

Preview

Try to type in more than three characters in the txtFld TextField in the view

TextPassWord Widgets – Uncommon Properties

Page 155: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

155© 2009 IBM Corporation

Course

Units:

Rich UI WidgetsRich UI Widgets

Text Widgets

Selection WidgetsSelection Widgets

Container Widgets and View Layout

HTML Widgets

IBM Widgets

Page 156: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

156© 2009 IBM Corporation

Workshop – Work With Rich UI Selection Widgets In this workshop, you will:

Create a new RUIHandler inside the mySamplesmySamples package Use the Rich UI Visual Editor to do initial web application layout Add several different types of Rich UI Text Widgets:

Checkbox & CheckBox Group ComboBox Single-selection List box Multiple-selection List box

Work with (customize) the essential U.I. Properties and Events for the RUIWidgets Using the Visual Editor Using EGL source code editing

Preview the web application – and verify “cause and effect”

Note – this is simply a learn by trial-and-error workshop, that asks that you experiment with different widget properties and events. Do not try too hard to match the PowerPoint screen captures exactly. And feel free to specify (experiment with) other settings for properties – just as long as:

You can tie the eventual (Previewed) result with a specified property value Time permits

Page 157: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

157© 2009 IBM Corporation

Rich UI Selection Widgets

The text widgets are used for input/output text values. There are five of them: CheckBoxCheckBox – For single or multiple selection (true/false) values Combo Combo – For single-selection values in a drop-down list ListList – For zeroone selected value in a scroll-able list ListMultiListMulti – For zero many selected values in a scroll-able list RadioGroupRadioGroup – For mutually-exclusive value selection

Workshop: Create a new RUIHandler in: \mySamples\\mySamples\ - named: selectionWidgetsselectionWidgets Add a 1-column Box1-column Box Into Into (inside) the Box the Box, add the following EGL Widgets:

CheckBoxCheckBox Combo Combo ListList ListMultiListMulti RadioGroupRadioGroup TextLabelTextLabel

Take all of the defaults for Properties - and for the Widget names

PreviewPreview

Page 158: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

158© 2009 IBM Corporation

Add the following function to your RUIHandler

Bind checkBoxFunction to the onClick event:

Preview and testPreview and test by clicking the checkbox

Optional workshops for checkboxes: Customize the CheckBox text

Customize the TextLabel’s properties

Create a “Check Box Group” – inside a new box

CheckBox Widgets – Common Properties and Events

Page 159: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

159© 2009 IBM Corporation

What if you wanted to hide a particular CheckBox within a group, programmatically? Answer:

In the RUIHandler, set the CheckBox’s visibility attribute to “hidden”

What if I want a CheckBox Group, but do not know at run-time, how many CheckBoxes will be in it?

Answer – there are two solutions:

1. Dynamic Widget run-time creation using the newnew widget syntax

2. Create an array of CheckBoxes

Add this function to your RUIHandler code:

PreviewPreview

Question: why are the CheckBoxes vertically oriented? How would you make the check box group orient horizontally?

Hint – put cbArray into its own box without a columns= property

OPTIONAL – CheckBox Widgets – Extended Dynamic Properties

Page 160: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

160© 2009 IBM Corporation

Most of the time, you will want to load and manipulate comboBoxes programmatically.

To load comboBoxes you will: Create and load a dynamic array of strings (most

likely through a service call) Calling a service will be covered later in the course

Invoke this function from your RUIHandler’s initialization() routine

To pre-select a specific row in the comboBox, you will use the widget.selection=“n” property

To test which comboBox value was selected, by the user, you will code conditional logic against the widget.selection property

Use the modified RUIHandler code shown here in your RUIHandler (Most of this code is in the slide ***Notes***Notes)

Add the following function to your RUIHandle

Bind comboBoxFunction to the onChange event:

Preview and testPreview and test by selecting a comboBox value

ComboBox Widgets – Common Properties and Events

Optional – The above case statement assumes there are 4 (or less) values in the array.Change the logic to be able to associate the comboBox selection, with the array entry.

Optional – The above case statement assumes there are 4 (or less) values in the array.Change the logic to be able to associate the comboBox selection, with the array entry.

Page 161: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

161© 2009 IBM Corporation

Single-selection listboxes are very much like comboBoxes

To load listBoxes you will: Create and load a dynamic array of strings (most

likely through a service call) Invoke this function from your RUIHandler’s

initialization() routine To pre-select a specific row in the listBox, you will

use the widget.selection=“n” property To test which listBox value was selected, by the

user, you will code conditional logic against the widget.selection property

Use the modified RUIHandler code shown here in your RUIHandler (Most of this code is in the slide ***Notes***Notes)

Add the following function to your RUIHandler

Bind listBoxFunction to the onClick event:

Preview and testPreview and test by selecting (clicking) a listBox value

ListBox Widgets – Common Properties and Events

Optional – The above case statement assumes there are 4 (or less) values in the array.Change the logic to be able to associate the listBox selection, with the array entry.

Optional – The above case statement assumes there are 4 (or less) values in the array.Change the logic to be able to associate the listBox selection, with the array entry.

Page 162: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

162© 2009 IBM Corporation

RadioButtons are similar to the comboboxes and listbox Widgets

As you did in the past few workshop steps: Modify the initialization() function to:

Load the RadioButton Group dynamically Pre-select a specific radio-button (note that in the

case of a radio-button, widget.selectedwidget.selected must be assigned the plain-text value to be selected)

Add the loadRadioButtons() function code (two new functions)

(In the Slide ***Notes***Notes)

Bind RadioGroupFunction to the onClick event

Preview and testPreview and test by clicking a radioGroup button

RadioButton Widgets – Common Properties and Events

Page 163: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

163© 2009 IBM Corporation

ListMulti Widgets are similar to single-select list boxes, except that users can – by pressing the Ctrl or Shift keys + clicking, select multiple rows in the box at runtime.

There’s no difference in loading and initializing ListMulti and single-select list widgets. However, in processing the selection, you will need to bind the widget’s selection property to an array as the user may select: 0, 1 or many rows

ListBox Multiple Select Widgets – Common Properties and Events – 1 of 2

As you did in the past few workshop steps:As you did in the past few workshop steps: Modify the initialization() function to:

Load the ListMulti Widget dynamically Pre-select a specific ListMulti values (note that in the case of a ListBox multiple, widget.selectionwidget.selection

must be assigned to an integer array, valued with the rows to be pre-selected) Add the loadListMulti() function code (two new functions (In the Slide ***Notes***Notes)

Page 164: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

164© 2009 IBM Corporation

Add a ButtonButton to the RUIHandler (at the bottom of the box)

Assign the Button’s onClickonClick event to: ListMultiFunctionListMultiFunction

PreviewPreview: Note the pre-selected rows in the ListBox Multi widget Select a few other rows, and press the Button

See Slide ***Notes on manipulating name/value pairs in selection See Slide ***Notes on manipulating name/value pairs in selection componentscomponents

ListBox Multi Widgets – 2 of 2 – Also name/value pairs in Selection Components

Add the new Button here

Page 165: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

165© 2009 IBM Corporation

Course

Units:

Rich UI WidgetsRich UI Widgets

Text Widgets

Selection Widgets

Container Widgets and View LayoutContainer Widgets and View Layout

HTML Widgets

IBM Widgets

Page 166: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

166© 2009 IBM Corporation

Container Widgets You will need strong Rich UI design skills, using container widgets (Box and Div

widgets) in order to realize a complex design with EGL Rich UI

This section aims at providing you with enough guided practice for you to use Box and Div widgets to realize any complex U.I. design

We will start with the Box widget – as this is an IBM/EGL-supplied widget, with a lower-barrier to entry in using and learning

In order to understand how to use Boxes, you will also need to learn about the concepts of: Container controls Children properties…All of which are based on the notion of a document model – that forms the underlying

generated-JavaScript source

Page 167: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

167© 2009 IBM Corporation

Concept Slides – initialUI, children, Document Model initialUI, children, Document Model and Box Widget Box Widget

Either following your instructor’s discussion, or on your own (reading) please be sure you understand the materials on the following slides, before continuing with the workshops:

InitialUI, Children and relationships among container and children widgets – essentially, the EGL Rich UI language elements that render your widgets according to your design and coding specifications

The Document “model” of an EGL Rich UI Application’s visual layout

Rich UI “Boxes” – Container widgets you will use to organize the visual elements in your web application

Page 168: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

168© 2009 IBM Corporation

InitialUI and childrenInitialUI and children

So far we have been introduced to a few simple EGL Rich UI concepts.

Others we have seen in passing, but have not looked at in-depth - In particular, the initialUI and children properties, which are very important Rich UI language features

initialUIinitialUI – A list (in EGL, an array) of things*** to be rendered on the page during it’s initial load. initialUIinitialUI is a property that can only be specified at the RUIHandler level This property can only be specified in the declaration of the RUIHandler

childrenchildren – A list (another array) of things*** to be rendered and attached to their respective parents Most Widgets will obtain the ability to have children A Box for example can have children. As children are added to a box, they are

rendered as new table columns or rows. The children property can be changed at run time. Any changes will be simultaneously

reflected on the page.

Note that, using initialUI and children we can create the kinds of hierarchically nested visual control-sets that effectively render data graphically in the browser – in a sort of “inverted tree” structure

Page 169: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

169© 2009 IBM Corporation

Rich UI and Inverted Tree-structured Web “Documents”

At it’s most basic, the elements of a web page are structured like an inverted tree The page itself is considered a web document*** All subsequent widgets are added to the document – in the parent/child dependent

relationship shown below. Each widget itself can have child widgets added to it Below is an illustration of a sample tree-based document. Note that the lower “branches” of

the tree are widgets that are: Related …and… Dependent

Document

TR (Row)

TD (Column)

DIV

Table

DIV Table Input Field Literal Text

TD (Column) TD (Column) TD (Column)

Page 170: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

170© 2009 IBM Corporation

InitialUI and Children and Container/Widget Relationships – Code View

Let’s take a look at the HelloWorld page we just created and see if we can find initialUI and children.

Both the children and initialUI properties are arrays ( hence the [ … ][ … ] ) Implying that both of these properties may contain more than one RUIWidget

If you declare multiple children/initialUI RUIwidgets, separate their names with a comma (see above)

The handler contains an initialUI property which contains the Box we created This means that the Box will be initially shown on the page

The Box itself contains the other widgets on our page (TextField, TextLabel, Button) If the Box is displayed on the page, it will of course contain its children

Page 171: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

171© 2009 IBM Corporation

InitialUI and Children – A More Complex Example

Note the following: initalUIinitalUI is a boxbox

No border/No color 1 “column” Three “controls”:

– isModalisModal Checkbox– Text TextLabel– Button – with an onClickonClick event

that fires off:

OKDialogOKDialog– A RUIWidget– Positioned (x/y) in the browser– Defined elsewhere in the project– Contains a child RUIWidget

named: “content”

Page 172: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

172© 2009 IBM Corporation

Rich UI Boxes

In web design, there are two fundamental HTML tags for laying out pages. Div Table

We’ll start with the Table, which is more prominent in business applications with lots of data entry.

So, how do we utilize HTML Tables from Rich UI?

Rich UI provides tables as a simple RUIWidget called a Box A box can be created like so

Hopefully by now you are seeing the pattern All UI Components (RUIWidgets) are declared just like any other EGL Variable

Ex. myString String;myString String;

Variable Name Variable Type Properties (within curly braces)

Page 173: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

173© 2009 IBM Corporation

Rich UI Box Widgets

A boxbox widget defines a rectangular-container-control that embeds and organizes other widgets.

You can indicate how many columns are in the box. If the number of columns is three, for example, the first three embedded widgets are on the

first row in the box, the fourth through sixth are on the second row, and so forth. If the number of columns is one, all the embedded widgets are arranged vertically.

The width of a column equals the width of the largest widget in the column

You can indicate whether the embedded widgets in a given column are aligned at the column’s center, right, or left.

Vertical and horizontal scroll bars appear if necessary to give the user access to widgets that scale outside of the browser/screen dimensions

The following properties are supported for boxbox widgets: alignmentalignment, which holds an integer value that indicates how the content is aligned in each

column: 00 for left-justify 11 for center 22 for right-justify

childrenchildren, which holds an array of widgets, as described in Widget properties and functions columnscolumns, which holds an integer that identifies the number of columns in the box

Page 174: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

174© 2009 IBM Corporation

Work With Rich UI Container Widgets In this workshop, you will:

Create a new RUIHandler inside the mySamplesmySamples package Use the Rich UI Visual Editor to do initial web application layout Add several different types of Rich UI Text Widgets:

Box– Different layout options– Using the Visual Editor to design your layout and doing your work from the EGL source code level– Using many or most of the box properties

Div Shadow

Work with (customize) the essential U.I. Properties and Events for the RUIWidgets Using the Visual Editor Using EGL source code editing

Preview the web application – and verify “cause and effect”

Note – this is simply a learn by trial-and-error workshop, that asks that you experiment with different widget properties and events. Do not try too hard to match the PowerPoint screen captures exactly. And feel free to specify (experiment with) other settings for properties – just as long as:

You can tie the eventual (Previewed) result with a specified property value Time permits

Page 175: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

175© 2009 IBM Corporation

RUIHandlers with More Complex Boxes – and using the Visual EditorRUIHandlers with More Complex Boxes – and using the Visual Editor

In this upcoming workshop, you will: Deepen skills using the Visual Editor Learn more about controlling form layout with RUIWidget boxes Embed boxes within boxes, to realize a more complex design

There will be 3 related workshops: boxSample1 – with one set of columns

boxSample1 – with two sets of columns

boxSample1 – with additional box layout styling

Page 176: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

176© 2009 IBM Corporation

Preparation – Analyze the Layout Before you start working on a web application, you will analyze the U.I. elements in

terms of: Layout – tables structure, etc. Types of components Component properties, size, dimensions, etc.

Here is boxSample1. From the snapshot note the following: Box widget – color, border and Alignment Box inside of box Aligned TextLabels and TextFields

Outer BoxOuter Box

Inner BoxInner Box

TextLabelsTextLabels TextFields

TextFields

Design NotesDesign Notes

You will use the RUIWidget boxes to:

• Organize the labels and fields (treat them as a unit)• Align the labels and fields• Provide:

• Dimension• Background color• Padding (space between)

The Outer Box is used to center the inner U.I. elements in the browser

The inner Box contains the two-column Label:FieldLabel:Field pairs

This is a typical U.I. pattern for an input single-record display, in vertically-aligned, rows/columns

Design NotesDesign Notes

You will use the RUIWidget boxes to:

• Organize the labels and fields (treat them as a unit)• Align the labels and fields• Provide:

• Dimension• Background color• Padding (space between)

The Outer Box is used to center the inner U.I. elements in the browser

The inner Box contains the two-column Label:FieldLabel:Field pairs

This is a typical U.I. pattern for an input single-record display, in vertically-aligned, rows/columns

Page 177: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

177© 2009 IBM Corporation

The Completed Workshop Viewed as an Inverted Tree Through the Outline ViewThe Completed Workshop Viewed as an Inverted Tree Through the Outline View

Note the nesting of the Boxes, labels and fields in the OutlineOutline view The OutlineOutline view documents the inverted tree structure of an EGL Rich UI web application You can also select (set focus to) an element by clicking on the element in the OutlineOutline view

Page 178: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

178© 2009 IBM Corporation

Using the Visual Editor - ReviewUsing the Visual Editor - Review

Like the Outline View, the Visual Editor shows the outline hierarchy (inverted tree view) of your web application.

You can drag & drop U.I. elements Into the box container

controls Below or above controls Next to controls

Placement ultimately depends on: Where in the tree you

drag & drop The alignment

specification The columns

specification (for a box)

Drag & Drop a Palette control ABOVE the top boxDrag & Drop a Palette control ABOVE the top box

Drag & Drop a Palette control inside of BoxOuter, between BoxNew and BoxMiddle

Drag & Drop a Palette control inside of BoxOuter, between BoxNew and BoxMiddle

Drag & Drop a Palette control inside of BoxNew, next to TextField10 (note that if BoxNew allows two columns the new control will be placed on the next vertical line down)

Drag & Drop a Palette control inside of BoxNew, next to TextField10 (note that if BoxNew allows two columns the new control will be placed on the next vertical line down)

Drag & Drop a Palette control inside of BoxRight, between TextLabel7 and TextField6

Drag & Drop a Palette control inside of BoxRight, between TextLabel7 and TextField6

Page 179: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

179© 2009 IBM Corporation

boxSample1 – Create the boxSample1 – Create the RUIHandler and Initial BoxRUIHandler and Initial Box

From your \mySamplesmySamples\ package, create a new RUIHandler named: boxSample1boxSample1

Using the Visual Editor, drag in a box – give it the following properties: name: BoxOuterBoxOuter Alignment: CENTERCENTER Columns: 11 BackgroundColor: BeigeBeige borderColor: LightSteelBlueLightSteelBlue borderStyle: groovegroove Width: 400400 Height: 300300

Page 180: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

180© 2009 IBM Corporation

boxSample1 – Add a TextLabel and an Inner BoxboxSample1 – Add a TextLabel and an Inner Box

From the Palette, add a TextLabelTextLabel inside BoxOuterBoxOuter

Use these attributes

From the Palette, drag a 2nd (inner) box into box into BoxOuterBoxOuter – placed below the TextLabelplaced below the TextLabel Name: BoxInner Columns: 2 Alignment: Center Width: 300 Height: 250

Note – Note – If you end up mis-spelling any of the RUIWidget names, you can make corrections in the Source view. You will have to correct all references to the widget (the declaration, and any references in the children=[ … ]children=[ … ] array)

Page 181: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

181© 2009 IBM Corporation

boxSample1 – Add a Series of TextLabels and TextFields to the InnerBoxboxSample1 – Add a Series of TextLabels and TextFields to the InnerBox

Using the Visual Editor, drag and drop a series (five each) of TextLabelsTextLabels and TextFieldsTextFields inside of the InnerBoxinside of the InnerBox Do not specify any custom

properties

Preview

Page 182: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

182© 2009 IBM Corporation

boxSample1 – Customize the Labels and TextFields with PaddingboxSample1 – Customize the Labels and TextFields with Padding

Enter SourceSource mode on the RUIHandler. Add a colon:: suffix and unique number to each TextLabel’s TextText property Add padding=4padding=4 to the TextLabel properties Add padding=2padding=2 to the TextField properties

You could of course, have done the above using the Visual Editor. But some things can be done faster in Source mode. With EGL Rich UI – as with most development activities it’s good to learn how to use the best tool for a given job

Preview

Page 183: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

183© 2009 IBM Corporation

boxSample1 – Customize BoxOuter – and Add Another Inner BoxboxSample1 – Customize BoxOuter – and Add Another Inner Box

Return to DesignDesign mode From OutlineOutline view, select: BoxOuter Select its PropertiesProperties tab

Change BoxOuter’s: Width: 600600 Height: 400400

From the Palette, Drag and Drop another Box into BoxOuterBoxOuter (below the TextLabelTextLabel and above BoxInnerBoxInner) Name: BoxMiddleBoxMiddle Columns: 22

Page 184: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

184© 2009 IBM Corporation

boxSample1 – Drag BoxInner Inside of BoxMiddleboxSample1 – Drag BoxInner Inside of BoxMiddle

Select - hold – drag & drop BoxInnerBoxInner into BoxMiddleBoxMiddle

From the Palette, Drag and Drop another Box into BoxMiddleBoxMiddle. Below (actually, next to) BoxInner Name: BoxRightBoxRight Columns: 22

Page 185: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

185© 2009 IBM Corporation

boxSample1 – Drag BoxInner Inside of BoxMiddleboxSample1 – Drag BoxInner Inside of BoxMiddle

As you did before, drag and drop a series (five more each) of TextLabelsTextLabels and TextFieldsTextFields inside of BoxRightBoxRight Do not specify custom

properties

Preview

Page 186: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

186© 2009 IBM Corporation

boxSample1 – Customize the TextLabels, Padding and other PropertiesboxSample1 – Customize the TextLabels, Padding and other Properties

As you did before, enter SourceSource mode on the RUIHandler. Add a colon:: suffix and unique number to each of the new TextLabel’s Text property Add padding=4padding=4 to the TextLabel properties Add padding=2padding=2 to the TextField properties

Remove the heightheight and widthwidth specification for BoxInner BoxInner (note that this has the effect of centering BoxInner + BoxRight inside of BoxOuter)

Preview

Page 187: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

187© 2009 IBM Corporation

boxSample1 – Customize BoxOuter (again) – and add yet another Inner BoxboxSample1 – Customize BoxOuter (again) – and add yet another Inner Box

Return to DesignDesign mode

From the Palette, Drag and Drop another Box into BoxOuterBoxOuter (below the TextLabelTextLabel and above BoxMiddleBoxMiddle) Name: BoxNewBoxNew

From the Palette, add a new TextLabel and a new TextField to BoxNewFrom the Palette, add a new TextLabel and a new TextField to BoxNew

Page 188: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

188© 2009 IBM Corporation

boxSample1 – Add a Submit Button to the Web ApplicationboxSample1 – Add a Submit Button to the Web Application

From the Palette, Drag & Drop a ButtonButton into BoxOuter (below BoxMiddle)

From the Button’s Properties, specify: Text: Add New Record

Preview

Page 189: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

189© 2009 IBM Corporation

boxSample1 – Customize U.I. PropertiesboxSample1 – Customize U.I. Properties

From the Properties of the new TextLabel, specify: text: Search Field:Search Field: paddingRight: 88

From the Properties of the new BoxNew, specify: paddingTop: 3333

PreviewPreview

Page 190: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

190© 2009 IBM Corporation

boxSample1 – Add a New Event and Bind it to the ButtonboxSample1 – Add a New Event and Bind it to the Button

With the ButtonButton selected - From EventsEvents Click: Add Event HandlerAdd Event Handler Name the Function: onClickonClick

(Still with the Button selected) from the onClickonClick Event, select the onClick Function

Page 191: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

191© 2009 IBM Corporation

boxSample1 – Add onClick Code boxSample1 – Add onClick Code and New TextLabeland New TextLabel

Enter SourceSource mode on the RUIHandler. Add (code) a new TextLabelTextLabel

named: msgFieldmsgField Add msgFieldmsgField to the childrenchildren

array of BoxOuterBoxOuter Add this ifif statement (you can

either code it, or copy/paste from the slide notes)

Preview Preview

Page 192: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

192© 2009 IBM Corporation

boxSample1 – Are We Done?boxSample1 – Are We Done?

Almost With the current design, if your search doesn’t return anything and the msgField.text

reminds the users of that, the message is not cleared out upon a subsequent good search. Also – using the Visual Editor tooling, please make the following enhancements to

msgField

Preview Preview

*** See Notes for code to clear the TextFields and msgField

*** See Notes for code to clear the TextFields and msgField

Page 193: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

193© 2009 IBM Corporation

WorkshopWorkshop – Layout and Boxes with Irregular Horizontal Widths

In this workshop, you will: Learn how to realize a standard web application layout, where the boxes contain elements

of differing lengths Learn how to use field styling to align individual text and field widgets

ConceptConcept:: When your U.I. elements are of differing sizes, you will not be able to utilize the block boxes as in the previous workshop. Instead, you will need to layout each individual row as a separate box:

Containing elements And vertically-aligned using explicit RUIWidget widths

See the above snapshot – then turn to the next slide for more analysis

Page 194: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

194© 2009 IBM Corporation

Understanding the Layout and Design Pattern From the snapshot of the Outline and Design views, note that you will nest individual

boxes containing labels and fields within each row of an outer box.

Outer BoxOuter Box

INDIVIDUAL

BOXES

FOR

EACH

ROW

INDIVIDUAL

BOXES

FOR

EACH

ROW

By nesting the individual row boxes, you have complete control over each element’s placement

Because there is no vertical box alignment across disparate boxes, you will need to align the columns via the width attribute

You’ll also have to use a style-attribute to right-justify text, when you can’t align the entire box due to conflicting U.I. alignment requirements (see the Directions and Phone/eMail Address rows above)

By nesting the individual row boxes, you have complete control over each element’s placement

Because there is no vertical box alignment across disparate boxes, you will need to align the columns via the width attribute

You’ll also have to use a style-attribute to right-justify text, when you can’t align the entire box due to conflicting U.I. alignment requirements (see the Directions and Phone/eMail Address rows above)

Page 195: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

195© 2009 IBM Corporation

Workshop – Create a new RUIHandler – Add in the Top ElementsWorkshop – Create a new RUIHandler – Add in the Top Elements

From \mySamplesmySamples\, create a new RUIHandler, named: customerSearchcustomerSearch Add a box, named: BoxOuterBoxOuter

Properties: Columns: 1 Font-size: 10 PT

Add a second box – inside of BoxOuter named BoxSearch Add a TextLabel named TextLabelSearch inside of BoxSearch

Property: Text: Search Text: Width: 88

Add a TextField named: TextFieldSearch next to TextLabelSearch,next to TextLabelSearch, inside of BoxSearchinside of BoxSearch

Add an HTMLHTML Widget inside of BoxOuter Property:

Text: <HR>

Preview

Page 196: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

196© 2009 IBM Corporation

Workshop – Add in the Row 1 ElementsWorkshop – Add in the Row 1 Elements

Add another box – inside of BoxOuter named BoxRow1BoxRow1 – under the HTML tag Properties:

Columns: 66 Align: RIGHTRIGHT

Inside of BoxRow1 add the TextLabelsTextLabels and TextFieldsTextFields shown below:

Notes: TextLabelCustid and TextLabelLastName - width: 88width: 88 TextLabelFirstName - width: 111width: 111

Page 197: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

197© 2009 IBM Corporation

Workshop – Add in the Row 2 ElementsWorkshop – Add in the Row 2 Elements

Add another box – inside of BoxOuter – below BoxRow1 – named BoxRow2 BoxRow2 Property:

Columns: 44

Inside of BoxRow2Inside of BoxRow2 add the TextLabelsTextLabels and TextFieldsTextFields shown below:

Notes: TextLabelPhone - width: 88width: 88 TextLabelMailAddress - width: 111width: 111 TextFieldMailAddress - width: 288width: 288

Page 198: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

198© 2009 IBM Corporation

Workshop – Add in the Row 3 ElementsWorkshop – Add in the Row 3 Elements

Add another box – inside of BoxOuter named BoxRow3BoxRow3 – under BoxRow2 Properties:

Columns: 66 Align: RIGHTRIGHT

Inside of BoxRow3 add the TextLabelsTextLabels and TextFieldsTextFields shown below:

Notes: TextLabelCity and TextLabelzip - width: 88width: 88 TextLabelState - width: 111- width: 111

Page 199: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

199© 2009 IBM Corporation

Workshop – Add in the Row 4 ElementsWorkshop – Add in the Row 4 Elements

Add another box – inside of BoxOuter – below BoxRow3 – named BoxRow4 BoxRow4 Property:

Columns: 22

Inside of BoxRow4 add the TextLabelsTextLabels and TextFieldsTextFields shown below:

Notes: TextLabelDirections - width: 88- width: 88 TextFieldDirections - width: 555- width: 555

Page 200: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

200© 2009 IBM Corporation

Workshop – Add the EGL Source Styling ElementsWorkshop – Add the EGL Source Styling Elements

From Source view: Change all padding=8 padding=3padding=3

Add the following style tag: to:

TextLabelDirectionsTextLabelDirections TextLabeleMailTextLabeleMail TextLabelPhoneTextLabelPhone

style = "text-align:right"

Page 201: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

201© 2009 IBM Corporation

Workshop – Finis!Workshop – Finis!

Preview!

Page 202: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

202© 2009 IBM Corporation

Workshop – Another Login Page? YesYes – another login page. But this one will allow you to utilize your newly-acquired

EGL Rich UI property and event-handling development skills. Also? This is more of an open-ended workshop – meaning that it lacks the detailed click-for-click

instructions you’ve gotten used to/dependent on

In this workshop, you will: Create another new Package in your EGL Rich UI Project Create a new RUIHandler inside the Package Use the Rich UI Visual Editor to do initial web application layout Customize some of the RUIHandler properties in EGL Add event-handling functions in the RUIHandler that Preview the web application and test your work Optionally add:

Styling elements – to enhance the U.I. Event handlers – to provide for immediate feedback to the user

Finished View

Page 203: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

203© 2009 IBM Corporation

Login Web Application Create a new package under \EGLSource\\EGLSource\ named: businessAppbusinessApp Inside of the \businessApp\\businessApp\ package, create a new RUIHandler, named: loginPageloginPage

You can style the colors and fonts as you like Add the IBM-supplied RUIWidgets as shown below:

Note the widget types, text properties, their nested placement and relationships, and the widget names (in parenthesis within the Outline view)

Hints: Box1 has columns=11, width = 333333, height = 222222, borderXXXStyle=grooveborderXXXStyle=groove Box2 has columns=22 The Password field is a

Page 204: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

204© 2009 IBM Corporation

Login Web Application For the Button, add an onClickonClick event handler to a function named: checkFieldscheckFields

See the screen capture of this code for some ideas of how to create Note that

There are other import statements (folded) The code for this version of the loginPage is in the ***Notes for this slide

Page 205: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

205© 2009 IBM Corporation

OPTIONALOPTIONAL Workshop – Check For UserID onFocusLost As a “warm-up” for the real event-driven programming you’ll be doing later in this

course, try the following: Add this function inside your RUIHandler:

Add this eventHandler to the User ID: TextField

PreviewPreview loginPage Enter a User ID Tab or click out

Page 206: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

206© 2009 IBM Corporation

Miscellaneous Widgets – Introduction and Beginning of WorkshopMiscellaneous Widgets – Introduction and Beginning of Workshop

There are a number of relatively easy-to-learn and use EGL Widgets left in the Palette that are useful: Button Hyperlink Image

Note that we will cover HTML and Grid widgets separately

Workshop: Create a new RUIHandler in: \\mySamplesmySamples\\ - named: miscWidgetsmiscWidgets Add a 1-column Box1-column Box Into Into (inside) the Box the Box, add the following EGL Widgets:

ButtonButton HyperlinkHyperlink Image Image

Take all of the defaults for Properties for the Widget names Add Text to match the Widget names

PreviewPreview Not very impressive, eh? Let’s jazz this up a little

Page 207: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

207© 2009 IBM Corporation

Add the following common Button tags to EGLRichUI.css: See ***Notes for source

Assign the .simpleRuiButton class to the Button

PreviewPreview

Enhance as follows: Assign the .searchButtonsearchButton class to the Button’s

class property Delete the text entry Specify a fixed width and height

PreviewPreview

Button Widgets – Common Properties and Events

Page 208: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

208© 2009 IBM Corporation

Specify the following custom properties for the Hyperlink:

PreviewPreview And click the hyper-link

OptionallyOptionally – change the URL or some of the Hyperlink references in the EGL source, and re-test

Hyperlink Widgets – Common Properties and Events

Page 209: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

209© 2009 IBM Corporation

Specify the following custom properties for the Hyperlink:

PreviewPreview And mouse-over the image

Add the following functions to your RUIHandler source:

Add the following Events to the Image widget:

PreviewPreview And mouse-over the image to see the rollover effect

Optional Optional (for supreme uber-techies):(for supreme uber-techies):

Work with the SpanSpan widget – by adding it in to this RUIHandler, and experimenting with its properties (note, use Content Assist to explore salient properties)

Graphic Widgets – Common Properties and Events

Page 210: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

210© 2009 IBM Corporation

Course

Units:

Rich UI WidgetsRich UI Widgets

Text Widgets

Selection Widgets

Container Widgets

HTML WidgetsHTML Widgets

IBM Widgets

Page 211: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

211© 2009 IBM Corporation

HTML Widgets – Concepts You may have existing HTML or HTML “code snippets” you wish to reuse

or re-purpose” in Rich UI applications. This is very straightforward to do, as follows: Create “inline HTML” – where you type the tags directly inside your RUI Widget (or

RUIHandler) Create “static” HTML – possibly your existing HTML, or new HTML you create using some

dedicated HTML editor (FrontPage, DreamWeaver, etc.) – then import the HTML into project and include it in your Rich UI page

The next few workshops will show examples of both

Where to learn HTML? Just about anywhere – but.. Especially – through free info on the web

http://www.w3schools.com/html/default.asp http://www.html.net/tutorials/html/

There’s no shortage of books either

In this section we will cover a few basic HTML tags: HR – Horizontal Ruler H1 – Heading tag Lists – Ordered and unordered DIV – a tag used to contain other content Table – a tag used to organize content Inline Frame

<html><html>

</html></html>

Note – you will not use HTML to create Web Pages

But you may want to use HTML tags to embellish your Rich UI applications – and/or to reuse pre-existing HTML resources.

So – essentially, you will want to know “about” HTML – and how to use HTML – but you won’t have to become an HTML programmer

Note – you will not use HTML to create Web Pages

But you may want to use HTML tags to embellish your Rich UI applications – and/or to reuse pre-existing HTML resources.

So – essentially, you will want to know “about” HTML – and how to use HTML – but you won’t have to become an HTML programmer

Page 212: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

212© 2009 IBM Corporation

HTML Widgets – Workshop Workshop:Workshop:

Create a new RUIHandler in: \mySamples\\mySamples\ - named: htmlWidgetshtmlWidgets Go immediately into Source view and add the source code in the Slide *** Notes*** Notes

<HR> tag

<H1> tag

List tags• Unordered• Ordered

Div Widget<Table> tag

<iframe> tag

Page 213: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

213© 2009 IBM Corporation

HTML Widgets – inline HTML Preview Preview

Click the Change HTML in EGL Change HTML in EGL button

Using GOOGLE or some other search engine, if you don’t know these HTML tags, look-up their definitions on the web

The next slide contains a quick studyguide to the HTML tags shown here

<HR> tag

<H1> tag

List tags• Ordered

Div Widget<Table> tag

<iframe> tag

List tags• Unordered

Page 214: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

214© 2009 IBM Corporation

HTMLHTML – QuickStart and “Survival Chart” Rules of the road:Rules of the road:

Most HTML consists of matching “tags” in the form of: <startTag> … content … </endTag>

– Example: <LI> My bulleted list </LI><LI> My bulleted list </LI>

Specific examples from the htmlWidgets view: <H1><H1> - a text heading tag – largest font size, default font (there exist <h1> <h6>, largest to smallest) <HR><HR> - creates a horizontal ruler (line) in the web page <UL><UL> - an “un-ordered” (un-numbered) list that consists of one-to-many:

<LI><LI> - List (or bulleted list entries) <OL><OL> - same as <UL> except creates numbered lists <DIV><DIV> - a container – consisting of one column and one row (like a one-column Box widget) <TABLE><TABLE> - a complex tag that organizes things like a two-dim table. Consists of:

<TR><TR> - rows <TD><TD> - cells

<IFRAME><IFRAME> - an inline frame. iFrames allow you to embed another RUIHandler (or another HTML or .JSP page for that matter) inline (inside) of an existing RUIHandler view

Notes - All of the above HTML tags and statements: Can be created statically (at design time) or dynamically using EGL RUI statements HTML tags have sub-properties, which are fully customize-able

Page 215: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

215© 2009 IBM Corporation

HTML Widgets – inline HTML Make the following modifications to the source:Make the following modifications to the source:

Change one of the <H1> to an <H5> tag – and change some of the text Change one of the <HR> tags as shown below

Change some of the text in the OLhtml widget Add an extra list: <li>…your text … </li><li>…your text … </li> tag-set inside the OLhtml widget Add a new textareatextarea widget: Add this new textArea widget as the final child in the DIV1DIV1 widget

Completely replace the existing tbl widget code with that found in the slide notes Make the following changes to the iFrame widget:

Save – check for syntax errors

PreviewPreview

Note – be sure to use Content Assist (Ctrl/Spacebar) to create new widgetsNote – be sure to use Content Assist (Ctrl/Spacebar) to create new widgets

Page 216: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

216© 2009 IBM Corporation

HTML Widgets – inline HTML Note the cause and effect revisions Note the cause and effect revisions

Blue, right-justified, no-shadow, thick lineBlue, right-justified, no-shadow, thick line

Your changes to the lists and headersYour changes to the lists and headers

Note cell color and text-color mods Note cell color and text-color mods

New View loaded into the <iframe>New View loaded into the <iframe>

New TextAreaNew TextArea

Page 217: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

217© 2009 IBM Corporation

OPTIONALOPTIONAL – Static HTML Served as a LocalHTML WidgetIf you have completely static (no need to dynamically build) HTML stream – or streams – it might If you have completely static (no need to dynamically build) HTML stream – or streams – it might

make sense to organize it as a set of HTML files, dynamically added to your View, but make sense to organize it as a set of HTML files, dynamically added to your View, but organized in your project as separate files (and not inline). This will allow you to create this organized in your project as separate files (and not inline). This will allow you to create this HTML using an intelligent editor (like FrontPage or DreamWeaver). HTML using an intelligent editor (like FrontPage or DreamWeaver).

Try the following:Try the following:

1.1. From Project Explorer, create a new From Project Explorer, create a new FolderFolder under under \WebContent\\WebContent\ named: named: HTMLHTML2. In this folder, create a new HTMLHTML file, named: colSpancolSpan

Note – you’ll find HTML files under the Web folder category

3. Replace the boilerplate HTML with the source found in the ***Slide Notes***Slide Notes – at the top (it’s a single line)

4. In your \EGLSource\ folder, create a new EGL package named: utilitiesutilities5. In the utilities package, create a new RUIHandler, named: localHTMLlocalHTML 6. Replace the “boiler plate” statements with the code also found in this ***Slide Notes***Slide Notes 7. In your HTMLWidgets RUIHandler, add a new widget for local HTML:

8. Add this widget as the bottom (final) child under the DIV1 widget

9. Preview

Page 218: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

218© 2009 IBM Corporation

Course

Units:

Rich UI WidgetsRich UI Widgets

IBM WidgetsIBM Widgets GroupingGrouping

TabFolderTabFolder

Simple MenuSimple Menu

DataGridDataGrid

Tree ControlTree Control

Drag & DropDrag & Drop

Popup PagesPopup Pages

Complex Layout UIsComplex Layout UIs

Page 219: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

219© 2009 IBM Corporation

Grouping Widgets are similar to fieldsets in HTML You can look up a fieldset tag online

Add the following new tag to EGLRichUI.cssEGLRichUI.css

Create a new RUIHandler in: \mySamples\\mySamples\ - named: groupingSamplegroupingSample Go immediately into Source view and completely replace the boiler-plate source code with

the code in the Slide *** Notes*** Notes

PreviewPreview

If time permits, follow the steps on the next slide to enhance the View

GroupingGrouping Widgets – Common Properties and Events – 1 of 2

Page 220: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

220© 2009 IBM Corporation

Select, copy & paste the grouping widget, the box and all of the textlabels and Select, copy & paste the grouping widget, the box and all of the textlabels and text fields (text fields (as shown belowas shown below) in the source. Make the following modifications) in the source. Make the following modifications

Change the text= and children= properties Change the box widget name – and change its children= identifier(s) Modify the TextLabel and TextField widgets (name and text properties)

Add groupAddr to the children property of box:Add groupAddr to the children property of box: Also add columns=1columns=1 as a property of box

Preview Preview

Optional Optional – add a button, that onClick, changesthe grouping.Text value

Grouping Widgets – Common Properties and Events – 2 of 2

Page 221: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

221© 2009 IBM Corporation

The Grouping widget actually has a number of additional properties you may want to utilize:

Legend font styling Legend block styling Thicker Grouping borders

Create a new RUIHandler in \mySamples\ named: groupingSampleExpandedgroupingSampleExpanded

Replace the boiler-plate code in this file with the copy & paste the grouping RUIhandler code in the Slide ***Notes.Slide ***Notes.

PreviewPreview (see results below)

Feel free to experiment with different Rich UI properties and events.

Optional Workshop - Grouping Widgets – Example View

Page 222: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

222© 2009 IBM Corporation

Tabs are common widgets for organizing dependent or related business data and functional views

The steps in creating a Tab widget will include: Create the RUIHandler Add a widget of type tabFolder to your RUIHandler

Use Content Assist (Ctrl+Spacebar) to allow the tooling to add any imports Add the tabFolder inside a box widget For each tab, use the tabFolderVar.addTab(“tab heading”,tabContent); API Preview

Let’s check things out…but before we start? We’ll learn how to make RUIWidgets out of RUIHandlers for component reuse

TabFolder Widget – Concepts

Page 223: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

223© 2009 IBM Corporation

So – while you’ve been creating RUIHandlers all along, in order to learn the Rich UI editor and the language terms & concepts, in reality (with your production projects), you will be creating more RUIWidgets than RUIHandlers – as RUIWidgets are the primary component of reuse within RUI technology

If you’re starting from scratch, it will probably make sense to create: A RUIHandler who’s only purpose is to act as a testing container for a single RUIWidgetA RUIHandler who’s only purpose is to act as a testing container for a single RUIWidget The RUIWidget – which you will be able to reuseThe RUIWidget – which you will be able to reuse

… and you’ll work within this process framework, during the final workshops for this course

But since you’ve got a # of useful widgets already (in the form of existing RUIHandlers) let’s see how to modify them and make them into RUIWidgets: Open the file – in Source mode Copy and paste the entire RUIHandler statement Comment out the original statement Modify the following lines:

1. Change: type RUIHandlertype RUIHandler type RUIWidgettype RUIWidget2. Add a new DivDiv widget (use content assist) – with a children =children = property that is the same as the

original initialUI = property

3. Change initialUI to targetWidget = (reference your new Div widget)

Creating RUIWidgets from RUIHandlers

1.1.

2.2.

3.3.

Page 224: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

224© 2009 IBM Corporation

Following these steps (repeated below for your convenience) – create RUIWidgets out of the following RUIHandlers: groupingSamplegroupingSample htmlWidgetshtmlWidgets miscWidgetsmiscWidgets textFieldstextFields

Steps: Open the file – in Source mode Copy and paste the entire RUIHandler statement Comment out the original statement Modify the following lines:

1. Change: type RUIHandlertype RUIHandler type RUIWidgettype RUIWidget2. Add a new DivDiv widget (use content assist) – with a children =children = property that is the same as the

original initialUI = property

3. Change initialUI to targetWidget=ui //(reference your new Div widget)

Workshop – Creating RUIWidgets out of RUIHandlers

1.1.

2.2.

3.3.

Page 225: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

225© 2009 IBM Corporation

Workshop:Workshop: Create a new RUIHandler in: \mySamples\\mySamples\ - named: tabSampletabSample Go immediately into Source view and (using Content Assist) add the source code shown

here

Notes: Notes: The TabFolder widget is an IBM-supplied custom widget that takes as a parameter a

TabFolderPage. The TabFolderPage widget allows you to define:

– The Tab label (name=)(name=)– The widget loaded in to the tab (widget=)(widget=)

The TabFolder also has a number of useful properties for customizing its behavior and UI. We’ll see these in an upcoming workshop

SaveSave and PreviewPreview

Tab Widgets – Common Properties and Events

Or…you can pick these source

statements from the Slide ***Notes

Page 226: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

226© 2009 IBM Corporation

Click each tab

Ensure that the widgetsembedded in the tabFolderPages still workas before

There may be additional functionality you’d want to see in tabFolders in order to handle There may be additional functionality you’d want to see in tabFolders in order to handle common dynamic U.I. requirements, such as:common dynamic U.I. requirements, such as: Pre-selecting a given tab:Pre-selecting a given tab:

Upon loading the viewUpon loading the view Explicitly Explicitly (as per the specifications in your business requirements – for example, if each tab represents a step in

a work-flow, opening a given tab programmatically, etc.)

Knowing Knowing (programmatically – from within your RUIHandler) what tab a user is on when an event what tab a user is on when an event occurs – and taking appropriate business logic actionoccurs – and taking appropriate business logic action

Adding graphics to the tab itselfAdding graphics to the tab itself Changing Changing (customizing) the default style properties the default style properties Explicitly sizing the tab controlExplicitly sizing the tab control Forwarding Forwarding (selecting “next tab”) with a button with a button

TabFolder Widget Workshop – Extending the Base Functionality

Page 227: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

227© 2009 IBM Corporation

Here’s a screen capture of our TabFolder view with a number of the desired techniques implemented:

Show the currently-selected tab

Graphics in the tabs Pre-select a tab Explicit size

Tab Widgets – Extended Functionality

To implement this yourself: From the slide ***Notes, copy/paste all of the code Replace your existing tabSample.egl code with the ***Notes EGL statements Preview

On the next slide we annotate some of the more important language constructs

Page 228: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

228© 2009 IBM Corporation

Read the annotated comments carefully – noting the operational language constructs

Optional Workshops: Pre-select a different tab, upon initial view rendering in the browserPre-select a different tab, upon initial view rendering in the browser Add a different graphic – to a different tabAdd a different graphic – to a different tab Add a different Rich UI Widget – to a different tab (suggestion, use a small simple widget)Add a different Rich UI Widget – to a different tab (suggestion, use a small simple widget)

Tab Widgets – Extended Sample – Optional Workshops

Page 229: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

229© 2009 IBM Corporation

Most business applications will drive their functionality from a common menu Rich UI apps will be no different

There are several menu widget options available: Standard (rich) menu widget – which:

Is recursive (allowing for multiple levels of sub-menu) Allows for embedding different widgets in-line

Simple menu widget – which: Allows for one level of sub-menu Is populated from string variables in a dynamic array

In this workshop, you’ll learn how to use the simple menu widget, and how to populate it from dynamic (server-side) data. Steps include: Creating a new RUIHandler that:

Calls a service (in our case, this will be a Library function) to populate the dynamic array of strings

Assigns the strings to the simple menu widget Customize the .css for the menu

Simple Menu Widgets – Common Properties and EventsStandard (rich) Menu Widget

simple Menu Widget

Page 230: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

230© 2009 IBM Corporation

Create a new RUIHandler in \mySamplesmySamples\ named: SimpleMenuDemoSimpleMenuDemo

Using Content Assist, edit the source code, and add the statements shown here

Note the following: Call to ServiceLibrary to load

the array Assignment to a dynamic

array of type any Defining a custom event

listener

PreviewPreview

Simple Menu Widgets – Coding Constructs

Page 231: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

231© 2009 IBM Corporation

Modify: \WebContent\css\EGLRichUI.css Under: .SimpleMenuTitle {Under: .SimpleMenuTitle {

Add: Add: – color: white;color: white;

Under: .SimpleMenuItem {Under: .SimpleMenuItem { Add: color: white;Add: color: white;

– Background-color: #5a9bd1;Background-color: #5a9bd1;– color: white;color: white;

Modify: SimpleMenuDemoSimpleMenuDemo Change the case statement shown belowChange the case statement shown below

Preview and try out the techniques Optionally add another when clause, to hit your companies web site on-select of

some other menu option

Optional – Simple Menu Widgets

Page 232: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

232© 2009 IBM Corporation

Tree Widgets are common and useful components for displaying hierarchical information: Menus and links Related application data:

Customers > Orders > OrderItems, etc Plain text …or…

Text + Graphics (icons)

Rich UI’s Tree widget is composed of: Tree Nodes – which contain the text and/or graphics Behaviors – which respond to user events

In our example, we’ll supply event-handlers for: onClick, onMouseOver, onMouseOut

The steps in creating a Tree widget include: Create the RUIHandler Add a widget of type Tree to your RUIHandler

Use Content Assist (Ctrl+Spacebar) to allow the tooling to add any imports Add the Tree inside a box widget Add code that:

Loads the Tree dynamically, from an external source Responds to user/browser events

– Collapse/Expand a tree category– Click a node

Preview

Tree Widgets – Concepts

Page 233: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

233© 2009 IBM Corporation

Tree Control WorkshopTree Control Workshop First create a new package under the EGLSource package named treeControltreeControl Next right-click over the \treeControltreeControl\\ package and create a new RUIHandler

named: TreeHandlerTreeHandler Copy & Paste everything in the Slide ***NotesSlide ***Notes over the boiler-plate EGL

statements

PreviewPreview

Note that the values in the tree come from the ServiceLibrary

These values would more typically be assigned via calls to back-end services But in this case, the Library call will do(We’ll learn how to call back-end services in an

upcoming section)

Now, let’s break down the code to create a tree widget

Page 234: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

234© 2009 IBM Corporation

Tree Control – EGL Rich UI Code – 1 of 3Tree Control – EGL Rich UI Code – 1 of 3 In the RUIHandler code for treeControl.egl there are quite a few new EGL Rich UI coding constructs. We have annotated them

in the source, but will attempt to amplify our explanations in these slides

Declarations:

Widget variables and properties

Of note the Tree widget: - Width, Padding - backgroundColor, behaviors The event-behaviors consist of: User click and user mouse-over (which generates a toolTip

TreeTooltip – a widget that allows Mouse-over help text

ToolTipResponse is a box widget

Tr TreeValues(0) is a standard EGL Dynamic array of strings that is Used to populate the Tree widget

EGL Business Logic:

In this initial function, the code: Retrieves the values into the dynamic array

Iterates over the array, and creates the initial (highest level – categories) tree nodes

Assigns the treeNodes to the Tree widget

Page 235: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

235© 2009 IBM Corporation

Tree Control – EGL Rich UI Code – 2 of 3Tree Control – EGL Rich UI Code – 2 of 3 Here are all of the EGL

functions bound to browser/events (except for onClick – which get’s its own slide)

Declarations:

showTooltip – returns an inline HTML formatted response to the user’s mouse-over. This function is activated by the Tree widget’s setToolTips property

The click function tests for which browser/user event occurred (that you have handled in this RUI code) – and invokes an EGL function based on the event

showFeedback and hideFeedback simply set a background color to a node of a tree, when you mouse-over it.

Page 236: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

236© 2009 IBM Corporation

Tree Control – EGL Rich UI Code – 3 of 3Tree Control – EGL Rich UI Code – 3 of 3The

handleNodeClick function:

Colors the clicked TreeNode

Changes the image (to the clicked TreeNode)

Changes the msg.text

Determines which TreeNode was clicked – and passes its array index to the expandedNode function

The expandNode function:

Iterates over the dependent array items

For the clicked TreeNode – a new set of widgets are dynamically created

Then the categories are re-built as treenodes and the nodes are assigned to the tree widget

Note:Note:Read the inline comments very carefully – as they Read the inline comments very carefully – as they document the Rich UI language features used to document the Rich UI language features used to implement a Tree Widget’s onClick functionalityimplement a Tree Widget’s onClick functionality

Note:Note:Read the inline comments very carefully – as they Read the inline comments very carefully – as they document the Rich UI language features used to document the Rich UI language features used to implement a Tree Widget’s onClick functionalityimplement a Tree Widget’s onClick functionality

Page 237: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

237© 2009 IBM Corporation

A Frameset-Style Web Page Template Layout – using .cssA Frameset-Style Web Page Template Layout – using .css Along with learning how to design your Views with boxes, you will want to develop a number of

U.I. templates, that act as the framework for your RUIHandler: Organization Layout Static text and graphics – common to most or all web pages

In this workshop, you will learn one approach to this – using DIV layouts and

custom .css definitions

Using this sample, you can customize to your specific U.I. templatized requirements

Page 238: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

238© 2009 IBM Corporation

Workshop – Create a Custom .css in your ProjectWorkshop – Create a Custom .css in your Project

From Project Explorer: Open the com.ibm.egl.education.widgetscom.ibm.egl.education.widgets project Expand \WebContentWebContent\ then expand \css\\css\ Copy floatLayout.css floatLayout.css - and paste it into the \WebContent\css\\WebContent\css\ package in your

EGLRichUIEGLRichUI project

Page 239: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

239© 2009 IBM Corporation

Workshop – A Standard Frameset-Style Template Layout Using .cssWorkshop – A Standard Frameset-Style Template Layout Using .css

Inside of the \mySamples\\mySamples\ package, create a new RUIHandler, named: frameSetLayoutframeSetLayout From the Slide ***Notes***Notes – copy and paste all of the replacement code From the EGL source editor, completely replace all of the boiler-plate code Review the codeReview the code briefly, noting the following elements:

Reference to the custom .css in the RUIHandler The various DIV widgets The child widgets inside the DIV widgets

Save and PreviewSave and Preview

Run in an external browserRun in an external browser

Resize the browserResize the browser

Try running the page in an external browserTry running the page in an external browser

Page 240: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

240© 2009 IBM Corporation

Workshop – Add Your Own Customized Widgets to the ViewWorkshop – Add Your Own Customized Widgets to the View

In this workshop, you’ll use the frameSetLayoutframeSetLayout RUIHandler to contain some of the other widgets – including their functionality. Eventually you’ll produce the view shown below

Page 241: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

241© 2009 IBM Corporation

Workshop – Create Widgets From RUIHandlersWorkshop – Create Widgets From RUIHandlers

Recall from the TabFolder workshop how to create RUIWidgets from RUIHandlers Change the type to RUIWidget Change initialUI to targetWidget (and move all elements into a single box, if necessary, as targetWidget can – at

most – refer to a single widget, not an array)

Start by making RUIWidgetsRUIWidgets out of: SimpleMenuDemoSimpleMenuDemo, and TreeHandlerTreeHandler

Make the following modifications to the frameSetLayout RUIHandler:

Add two new boxes to the header

Add the Tree widget in to the lefDiv

Add a center-aligned graphic (see code) into the footerDiv

Add a # of boxes with children as shown here

Add image widgets, with src= properties as shown here

Add the TreeHandler and SimpleMenuDemo widgets

Page 242: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

242© 2009 IBM Corporation

Workshop – Preview the frameSetLayout RUIHandlerWorkshop – Preview the frameSetLayout RUIHandler

Feel free to experiment with: U.I. properties of the existing widgets; add other widgets into the layout divs; add browser/user event-behaviors you’ve learned

Page 243: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

243© 2009 IBM Corporation

(Run-time) Drag & Drop Programming Techniques Drag & Drop Programming Techniques

Run-time Drag & Drop operations refer to Rich UI applications that allow users to pick up (select – drag) and drop a piece of data or an image – on top or inside of some other some other field or control in the browser. Upon drop some event is fired off, such as: A value is changed in a target input text field A total is updated – say, as a result of adding a retail item to a shopping cart A row (or rows) are moved from one table to another Etc.

This kind of live simulation (similar to the control board in “Minority Report”) is very appealing to users – as it simplifies their workflow.

As you can imagine, programming this in JavaScript/HTML is no walk-in-the-park. However EGL Rich UI provides language constructs to simplify the effort.

They include: Events for selecting, dragging and dropping A means of creating a temporary container with the dragged control inside All the rest of the Rich UI coding structures for advanced dynamic user interface work

In this workshop, you will create a RUIHandler like this – that allows browser/ruin-time Drag & Drop behavior for:

- Text values- Graphics

Page 244: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

244© 2009 IBM Corporation

Workshop – A Run-Time Drag & Drop RUIHandlerWorkshop – A Run-Time Drag & Drop RUIHandler

Inside of the \mySamples\\mySamples\ package, create a new RUIHandler, named: dnddnd From the Slide ***Notes***Notes – copy and paste all of the replacement code From the EGL source editor, completely replace all of the boiler-plate code Review the codeReview the code briefly (really briefly – a detailed walk-through follows starting on the next slide)

Save and Preview. Drag & Drop the text field Save and Preview. Drag & Drop the text field

Drag and Drop some of the graphic items onto the Shopping CartDrag and Drop some of the graphic items onto the Shopping Cart

Page 245: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

245© 2009 IBM Corporation

DND RUIHandler – DND RUIHandler – Fields and PropertiesFields and Properties

Of note: The “to-be-dragged” widget must

have three required eventHandlers that reference EGL functions:

onStartDrag onDrag onDropOnTarget

An absolute-positioned shadow container widget will be used to contain the dragged widget.

What this implies, is that: When you start dragging

the onStartDrag function is invoked (this code is shown on the next slide)

The function in your code will “copy” the dragged widget inside a Shadow container that is used to show what’s being dragged on-screen

It looks like you’re dragging the widget but you’ve made a temporary copy of the widget and are dragging the copy around inside a new, dynamically created container

We have defined a separate group of functions for dragging the image widget. This is not technically necessary, but will make understanding the example easier.

Page 246: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

246© 2009 IBM Corporation

DND RUIHandler – Functions for Dragging & Dropping the Text WidgetDND RUIHandler – Functions for Dragging & Dropping the Text Widget

Of note: The valueItems() function simply

fills in a dynamic record array of: Graphic URL strings Item price and description

strings

The start function is invoked for the widget with the onStartDrag event handler. This function creates the new, temporary (shadow) container, and in it, creates a new TextLabel and assigns it the text value from the dragged widget

It makes the shadow container visible

The drag function is invoked for each mouse movement. It places the shadow container at absolute x/y coordinates +4 from the cursor. If the widget you’re hovering over is the text2 (our target) widget, it shows you this, by highlighting the background

The drop function sets the text2 widget’s value equal to the dragged widget’s.text value. It also hides the shadow container and returns the text2 widget’s background to the original (white) color

Page 247: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

247© 2009 IBM Corporation

DND RUIHandler – Functions for Dragging & Dropping the Image WidgetDND RUIHandler – Functions for Dragging & Dropping the Image Widget

Of note:

Like the previous start function, this function is invoked for the widget with the onStartDrag event handler. This function creates the new, temporary (shadow) container, and in it, creates a new image widget and assigns it the src value from the dragged widget. It also makes the image widget opaque

It makes the shadow container widget visible

The drag function is invoked for each mouse movement. It places the shadow container at absolute x/y coordinates +4 from the cursor. If the widget you’re hovering over is the cartImage (our target) widget, it shows you this by creating a thin gray border around the image.

The drop function updates a number of internal values with the value from the associated (current) image from the dragged widget

It also hides the shadow container and returns the boxCart’s widget’s borderWidth back to zero.

Page 248: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

248© 2009 IBM Corporation

Optional Workshop Your Very Own Drag and Drop-Able Top 5 List – 1 of 3Your Very Own Drag and Drop-Able Top 5 List – 1 of 3

Assume that you were to create a Drag & Drop widget as follows: There are five TextField widgets – that are initially valued as You need to allow users to:

Enter new values (these are after all, TextFields) Drag and drop individual TextField widgets on top of other

TextField widgets – swapping the contents of both the dragged and dropped widgets

Process: Create a new RUIHandler Copy/Paste the following artifacts from the DND RUIHandler into your new RUIHandler:

Shadow myTextField The start(), drag() and drop() functions

Then, make the following code additions/modifications to the widget declarations

If you’re pressed for time, check the Slide ***Notes

Page 249: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

249© 2009 IBM Corporation

Changes to the start() function

Add this function:

Changes to the drag() function

Optional Workshop Your Very Own Drag and Drop-Able Top 5 List – 2 of 3Your Very Own Drag and Drop-Able Top 5 List – 2 of 3

Page 250: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

250© 2009 IBM Corporation

Optional Workshop Your Very Own Drag and Drop-Able Top 5 List – 3 of 3Your Very Own Drag and Drop-Able Top 5 List – 3 of 3

Changes to the drop() function

A complete sample solution is in the Slide ***Notes ***Notes (you’re welcome)

Page 251: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

251© 2009 IBM Corporation

Data Table WidgetData Table Widget

Data Tables are a very popular and common way to organize and display data in business applications.

EGL Rich UI ships with a powerful and flexible widget that allows the programmer to display data and manipulate it in many ways. It’s called the Grid widget.

When we are done with this workshop having learned how to use the Grid widget, we will have created a view similar to this…

AlternateRowColors

Sort-able Column Headers

Page 252: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

252© 2009 IBM Corporation

Data Table Workshop – Create New Package and LibraryData Table Workshop – Create New Package and Library In order to complete this exercise, we will need some data to work with For learning purposes, we will provide you with some hard coded data Let’s first create a package for our data. Right-click over the EGLSource source folder and select New EGL Package

At the screen that pops-up, name the package customerData

Next right-click over the customerData package and create a new EGL Library Name the file CustomerInfo

Page 253: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

253© 2009 IBM Corporation

Create customerInfo Library Records and DataCreate customerInfo Library Records and Data Delete everything in the customerInfo file.

You should now have a file with nothing in it

Copy the code in the notes section of this slide and Paste it into the customerInfo file.

You should have no errors and see something like the following!

This file contains a record definition, which uses data items declared above the record.

The library then declares an array variable of the record type and assigns it values Now that we have data to work with, let’s move on to creating a Data Table

Page 254: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

254© 2009 IBM Corporation

Create New Package and RUIHandlerCreate New Package and RUIHandler First let’s create a new package Right-click over the EGLSource source folder and select New EGL Package

At the screen that pops-up, name the package dataGrid

Next right-click over the dataGrid package and create a new EGL Rich UI Handler Name the file DataTableBasics

Click Finish

Page 255: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

255© 2009 IBM Corporation

Create Your First Grid WidgetCreate Your First Grid Widget Now, let’s drag a Grid widget onto the RUIHandler

Make sure to drag the Grid from under EGL Widgets and not Dojo

When asked for a variable name of your Grid, name it myFirstGrid

Now switch to the source view of the Rich UI Editor Don’t be intimidated by the code!

We will make sense of it

Page 256: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

256© 2009 IBM Corporation

Customize the Grid Widget PropertiesCustomize the Grid Widget Properties First let’s experiment with the columns property

The columns property takes an array of GridColumn RUIWidgets The GridColumn RUIWidget itself has several properties including

– NameName – The actual name of the field in the record to be displayed (case sensitive)

– DisplayNameDisplayName – The name to be used as the column header when the Grid is rendered on the page

– WidthWidth – The width of the column

Adjust the variable declaration so it looks as follows

Next, delete the data property from the myFirstGrid variable declaration (and don’t forget to delete the trailing comma after the close square bracket – see screen capture) Add the following line of code in the initialization function

Note that .data is the property of the Grid RUIWidget that corresponds to the detail rows displayed in the grid at run-time. The actual values can be sourced from a service or library call, but what’s significant here, is that a grid widget’s .data property must be assigned to a dynamic array of type: any[];

Page 257: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

257© 2009 IBM Corporation

Preview Grid Widget Preview Grid Widget (so far) Save the page and then go to the

Preview view of the EGL Rich UI Editor Currently only two columns are being

displayed, even though each array record of data passed to the Grid widget contains nine fields (we’ll get to the other seven fields later)

Note the alternating row colors

Note the gray header cells

Page 258: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

258© 2009 IBM Corporation

Add Additional Grid ColumnsAdd Additional Grid Columns Go ahead and add the following new GridColumns to the Grid variable’s columns

property

You should now see a data table on the page with five columns and 14 rows. You should also understand the relationship between dynamically declaring new grid columns, and the columns displayed in a dataGrid widget

Let’s take a further look into some of the other Grid properties BehaviorsBehaviors – The ability to add behaviors to the Grid as a whole HeaderBehaviorsHeaderBehaviors – The ability to add behaviors to just the column headers of the data

table

Page 259: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

259© 2009 IBM Corporation

What is a “Behavior”?What is a “Behavior”?An EGL Rich UI widget behavior is a defined event handler that is invoked An EGL Rich UI widget behavior is a defined event handler that is invoked when certain elements in a widget are created.when certain elements in a widget are created.

Behaviors typically do things like change presentation characteristics, add Behaviors typically do things like change presentation characteristics, add extra widgets, or add extra event handlers.extra widgets, or add extra event handlers.

For Grid, behaviors can be specified on both header cells and data cells. For For Grid, behaviors can be specified on both header cells and data cells. For Menu, behaviors exist on menu items.Menu, behaviors exist on menu items.

For Tree widgets, a behavior is invoked for each tree node being created.For Tree widgets, a behavior is invoked for each tree node being created.

What is a “Behavior”?What is a “Behavior”?An EGL Rich UI widget behavior is a defined event handler that is invoked An EGL Rich UI widget behavior is a defined event handler that is invoked when certain elements in a widget are created.when certain elements in a widget are created.

Behaviors typically do things like change presentation characteristics, add Behaviors typically do things like change presentation characteristics, add extra widgets, or add extra event handlers.extra widgets, or add extra event handlers.

For Grid, behaviors can be specified on both header cells and data cells. For For Grid, behaviors can be specified on both header cells and data cells. For Menu, behaviors exist on menu items.Menu, behaviors exist on menu items.

For Tree widgets, a behavior is invoked for each tree node being created.For Tree widgets, a behavior is invoked for each tree node being created.

Add New BehaviorsAdd New Behaviors Edit the grid variable declaration again to add the following behaviors property.

The behaviors property accepts an array of behaviors. Add the behavior outlined in red below

Save the page, Preview and examine the results. Notice how the cells (except for Customer ID) have almost no padding now Why not the Customer ID column?

How would you change the grid code so that Customer ID does not have a

fixed-width?

Page 260: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

260© 2009 IBM Corporation

Add a GridSelectorAdd a GridSelector Next, let’s create a variable of type GridSelector

Do so anywhere inside of the RUIHandler (and outside of the initialization function)

Now return to the behaviors property of the Grid and add the following property (don’t forget the trailing comma after GridBehaviors.tightCells,)

Save the page and Preview. Notice the results: Clicking inside of a row will fire off the GridSelectorGridSelector event and turn the row green Holding down the CtrlCtrl key will allow you to click and select multiple rows

Page 261: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

261© 2009 IBM Corporation

Add a Column SorterAdd a Column Sorter How about another behavior?

Go ahead and create a new variable of type GridSorter inside of your RUIHandler

Now add gridSorter.columnSortergridSorter.columnSorter property to the headerBehaviors array

Save the page and view the results. Click the column headers to re-sort the rows

Page 262: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

262© 2009 IBM Corporation

Add a Column Header TooltipAdd a Column Header Tooltip Another very popular feature in many applications is what’s called a ToolTip. A tool

tip is a message that will pop-up when a user mouses (hovers) over something. Create the following variable of type ToolTip, and the function called

headerTooltips. Copy/Paste code available in the notes

Now return to the headerBehaviors property of the Grid and add the following tool tip as a grid column header behavior. Notice that you are referencing the function (headerToolTipss) and not the Tooltip variable

Page 263: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

263© 2009 IBM Corporation

Drag & Drop – Add 2Drag & Drop – Add 2ndnd Grid Grid Save the RUIHandler code, and note the new functionality

Now that we have explored many of the functions that the Grid Widget offers, let’s take a look at two final use cases: Row Drag & Drop Table data cell Drag & Drop

In the same RUIHandler (DataTableBasics.egl) create the following new Grid This Grid will serve as the empty Grid that data is dropped into

You may get errors because of missing import statements, press Ctrl+Shift+OCtrl+Shift+O to fix these errors

Page 264: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

264© 2009 IBM Corporation

Add Drag & Drop SupportAdd Drag & Drop Support Next, let’s add some code onto the RUIHandler that will give us the browser/run-time

Drag & Drop support we learned about earlier in this section of the course. For this part of the lab, Copy/Paste code is provided in the slide ***Notes***Notes.

Steps: Copy the Slide *** Notes code now. Place this code anywhere within the EGL functions section of the RUIHandler Press Ctrl+Shift+O – to resolve missing imports for these new statements

By doing this you have: Created a second grid and given it no data Placed code that will allow for drag and drop between the two grids onto the RUIHandler

Now that we’ve got two grids, let’s put them into Rich UI box, in order to get them next to each other. Add the following code to the RUIHandler (Preferably at the top – and don’t forget to press Ctrl+Shift+O to add referenced widget imports)

Note that we are creating a box and giving it three children. The first two children are Box’s themselves created implicitly (and given our Grids as children). The last child is a Widget which will appear during drag and drop (it is initially set to visibility = hidden)

Page 265: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

265© 2009 IBM Corporation

Drag & Drop – Event-Handler Bindings for Drag & Drop OperationsDrag & Drop – Event-Handler Bindings for Drag & Drop Operations

Now that we’ve created a new Box to house our Grid’s, let’s go ahead and adjust our RUIHandler’s initialUI property to take the new Box instead of our first Grid

Finally, we need to add some more properties to myFirstGrid

Note that the functions referenced by these properties were defined inside the copy/paste code on the previous slide

Save and Preview Click and select one or more rows as you did before, from myFirstGrid (on the left). Then, drag them to mySecondGrid (on the right), dropping them on the grid column header

to add the rows. Check out all the other grid behaviors to verify that they have been unaffected by adding

your new functionality

Page 266: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

266© 2009 IBM Corporation

Data Table – With Row Drag & Drop: PreviewPreview

Optional workshop: From inside the myFirstGrid’smyFirstGrid’s behaviorsbehaviors and headerBehaviorsheaderBehaviors, copy/paste properties, and enable mySecondGridmySecondGrid for: Alternate row colorsAlternate row colors Column sortColumn sort Tight cellsTight cells

Page 267: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

267© 2009 IBM Corporation

Data Table – Drag & Drop of Individual DataTable CellsData Table – Drag & Drop of Individual DataTable Cells

Drag & Drop is so popular with Web 2.0 applications, that we’re going to cover one final use case – which is cell-by-cell Drag & Drop (see the screen capture below).

As we’ve done in previous workshops, we will annotate and walk through the important aspects of the EGL code

Note – the code in this Drag & Drop sample is in the: com.ibm.egl.education.widgets com.ibm.egl.education.widgets project: Feel free to open and Preview before continuing

on with these slides.

Page 268: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

268© 2009 IBM Corporation

Drag & Drop of Individual DataTable Cells – Annotated Code – 1 of 2Drag & Drop of Individual DataTable Cells – Annotated Code – 1 of 2 Recall from your previous Drag & Drop examples that you need to define: 1. behaviors for enabling the Drag & Drop (in this

example the behavior is: enableCellDraggingenableCellDragging. 2. A Shadow widget – which is an HTML <DIV> tag, that will be dynamically created at run-time, to contain the value of what is selected and dragged (in this case, a dataGrid cell value).

This is what’sbeingdragged

Page 269: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

269© 2009 IBM Corporation

Drag & Drop of Individual DataTable Cells – Annotated Code – 2 of 2Drag & Drop of Individual DataTable Cells – Annotated Code – 2 of 2 Compare this with the previous Drag & Drop example. Note that the only difference between the two is that in this example,

you’re dragging a table cell - In actuality? An HTML: <TD> value </TD><TD> value </TD>. Study the code below. You should recognize the EGL Rich UI coding elements annotated for here and more importantly, the coding pattern to do cell Drag & Drop.

Page 270: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

270© 2009 IBM Corporation

Another Data Table Use Case – a Paging Grid – 1 of 3Another Data Table Use Case – a Paging Grid – 1 of 3 You will definitely need to create a page-able dataGrid for your Rich UI applications. To help

you with this, IBM has pre-defined just such a widget, that allows you to customize things such as # of rows displayed, etc. Create a new EGL Rich UI Handler called PagingGridBasics under the dataGrid package In your new RUIHandler, code the following PagingGrid (or grab the Copy/Paste code for this snippet

from the Slide ***Notes, and replace your entire boiler-plate code). Note the new widget features:

PagingGrid widgetPagingGrid widget visibleRows propertyvisibleRows property

Preview Preview

Page 271: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

271© 2009 IBM Corporation

Another Data Table Use Case – a Paging Grid – 2 of 3Another Data Table Use Case – a Paging Grid – 2 of 3 Try changing the following properties of the PagingGrid view – and enhance it as follows:

Add additional columns (note – get the specifics by looking at customerInfo.Customers) Change the visibleRows Change the PagingGrid’s general properties:

BackgroundColor, Height, Width, Color, borderColor/BorderStyle/BorderWidth

OPTIONAL workshop: From the dataTableBasics.egl, copy the code in to do:

Grid.behaviors:– Alternate row colors– Tight cells– Row selection

Grid.headerBehaviors– Column sorting– Gray cells– Tooltips

See next slide for a screen capture of the code needed to the optional lab

Page 272: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

272© 2009 IBM Corporation

Another Data Table Use Case – a Paging Grid – 3 of 3Another Data Table Use Case – a Paging Grid – 3 of 3 When all else fails, use this… Code what’s below, or hit the Slide ***Notes for a copy/paste solution

Also – remember that you will need to add in the imports (Ctrl/Shift/OCtrl/Shift/O)

Page 273: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

273© 2009 IBM Corporation

One more OPTIONAL Use One more OPTIONAL Use CaseCase

(Just ‘cause we knew you’d ask) How would you get this

Paging buttons relocated: Bottom Right-justified

Give up? Not so fast… From PagingGridBasics.egl, double-click on: pagingGridpagingGrid Press F33 – enough times to open the pagingGrid.egl source code in the Editor Find the targetWidget=targetWidget= property … what widget does it point to? Right: uiui - a plain old box, with two children. Okay, so how would we switch the button and

grid order? Right. Switch their order inside the box properties

Now (the $64,000 question) – “How would you right-justify the buttons in the button box”? RIGHT!RIGHT! Add: alignment=1, to the gridgrid properties

Moral: “It’s all just EGL”, Chris Laffra, Rich UI Language Architect, February 7th, 2009

Page 274: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

274© 2009 IBM Corporation

Another Use Case – How to Reference the “Selected Row”Another Use Case – How to Reference the “Selected Row” One question that probably will come to mind sooner – rather than later – is the question of, “how do I select

a row in a dataGrid – and take some action based on the row selected?” We’ve already seen that you can automatically (calling the gridSelector behavior widget) turn the selected

row a different color – but how about actually doing something tangible with the row selected? Like opening another dataGrid with rows dependent upon the row selected, etc

It’s actually very easy to do this – as it’s already built-in to the gridSelector’s functionality. From the PagingGridBasics’ code: modify + add the following:

Change to gridSelect properties. Ad a behavior to run on row click:

onClick of a dataTable row, use the first occurrence in the selection[…] array (which references the row selected)

Page 275: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

275© 2009 IBM Corporation

Do We Have Time For One More Use Case? (Substituting Other Widget Types in dataGrid Rows)Do We Have Time For One More Use Case? (Substituting Other Widget Types in dataGrid Rows)

Another typical Use Case revolves around substituting complex widgets into dataGrid Rows (in place of the default TextLabels). This is relatively easy to do, but involves using a new IBM-supplied widget, called the EditableGrid.

Assume you had to create the following view:

Where: All of the fields are editable Checkboxes are used for boolean datatypes ComboBoxes can be used for selection controls The RUIHandler responds to each update ‘event’ – allowing you to save or persist changes

Let’s see how to pull this together

Page 276: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

276© 2009 IBM Corporation

Substituting Other Widget Types in dataGrid Rows – 1 of 4Substituting Other Widget Types in dataGrid Rows – 1 of 4

In the \dataGriddataGrid\ package, create a new RUIHandler, named: rowWidgetSubrowWidgetSub Copy and paste the code from the Slide ***Notes, over the boiler-plate statements Save and Preview. Note the run-time behavior:

Sorting Row mouse-over Row selection

Modify a value: A text field A check box Select a different state

Move to (select) a new row

Note that the RUIHandler is “aware” of what row (and what value) has been updated

Let’s look at the EGL language and coding patterns to do this…

Page 277: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

277© 2009 IBM Corporation

Substituting Other Widget Types in dataGrid Rows – 2 of 4Substituting Other Widget Types in dataGrid Rows – 2 of 4

From the EGL statements note the following: Standard RUIHandler declaration – although the code to implement the Editable Grid columns is in the

start function (next slide) Standard Grid widget functionality for: Sorting, Selection New widget type – Editable grid – that’s been included in the: com.ibm.rui.widgets.education project In this new widget, we are mixing implementations of:

Behaviors defined in this RUIHandler Behaviors defined in the standard gridSelector and gridSorter widgets

An array of string values (that will ultimately end up as a combo-box)

Page 278: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

278© 2009 IBM Corporation

Substituting Other Widget Types in dataGrid Rows – 3 of 4Substituting Other Widget Types in dataGrid Rows – 3 of 4

In the start()start() function we: Invoke a widget function to define individual columns for the grid – setting custom properties and

specifying validatorsvalidators and/or validValuesvalidValues: Note that by default:

- Boolean fields Checkboxes

- Other types Edit-able Input fields

- validValues comboBoxes

In the grid.setData, we assign anany[] array – as usual

Page 279: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

279© 2009 IBM Corporation

Substituting Other Widget Types in dataGrid Rows – 4 of 4Substituting Other Widget Types in dataGrid Rows – 4 of 4

In the remaining EGL functions, we’re exposing the Rich UI coding techniques used to do things such as: Mouse-over and Cell-hover Alternating rows Grid value-changed event-listener (defined)

These could be embedded in the Editable grid, but are shown here to illustrate the nature of the coding patterns

Page 280: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

280© 2009 IBM Corporation

Popup pages or dialogs are ubiquitous requirements for business applications. And even have been for decades. We’d better learn how to implement them in Rich UI.

They relate to some parent widget’s information typically contain: Dependent or expansion information on data in some parent widget Capturing or selecting information in a display that would simplify data entry Showing some exceptional condition or information in an eye-catching manner

The curious thing? You already have the tools. (No way? Yes way.) Steps: Design the popup page (nothing new here) – except Code the properties to:

Hide/Show the box that contains whatever widgets (or just a widget) you wish to pop up (If placing the Popup relative to another widget on-screen) capture and utilize the x/y coordinates

of the parent widget – see example Code the necessary event-handlers for the processing in the Popup

In the workshop, we’ll create a RUIHandler which contains a Popup that displays a list of states for selection

You will activate the Popup by double-clicking in a field

EGL Rich UI Programming – Popup Dialogs

Page 281: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

281© 2009 IBM Corporation

Create Popup RUIHandler – Code Explanation 1 of 2Create Popup RUIHandler – Code Explanation 1 of 2 In the \mySamples\ folder create a new RUIHandler named: dialogHandlerdialogHandler From the Slide ***Notes – copy and paste the code therein, over the boiler-plate

statements Save Preview – Click in the State textField Now let’s break the Rich UI code constructs down…

Consider the following… In fieldStatefieldState – we define an onClick event The statesstates string array is just that. You would populate it typically using a call to a Web

Service (next section of this Tutorial) The stateValuesstateValues widget is our popup. It needs its own onClickonClick event-handler (function).

It also needs to be initially hidden and its position must be absolute, in order to dynamically assign it to the x/y coordinates of fieldStatefieldState

Page 282: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

282© 2009 IBM Corporation

Create Popup RUIHandler – Code Explanation 2 of 2Create Popup RUIHandler – Code Explanation 2 of 2 From initialization, we invoke the function (populateStates) to create the internal array selectState is the function that:

Assigns the x/y coordinates of stateField to the popup list widget And unhides the widget

singleSelFunc assigns the selected value of list widget to fieldState.text, and re-hides the widget

Page 283: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

283© 2009 IBM Corporation

OPTIONAL – Create Your Own PopupOPTIONAL – Create Your Own Popup On your own (or using the screen-shot given

below) – create a popup like the one shown here to capture a comment and re-display it

Page 284: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

284© 2009 IBM Corporation

Course

Units:

Rich UI and ServicesRich UI and Services

Web Services and Rich UI Architecture Web Services and Rich UI Architecture

Calling a Service - Process Flow (steps)Calling a Service - Process Flow (steps)

Rich UI Service Calls Language ConstructsRich UI Service Calls Language Constructs

Service Calls and the Rich UI Event-Driven Service Calls and the Rich UI Event-Driven

Programming ModelProgramming Model

Workshops and ExamplesWorkshops and Examples

Calling a 3Calling a 3rdrd Party Service Party Service

Calling a Mainframe CICS/COBOL ServiceCalling a Mainframe CICS/COBOL Service

Creating and calling an EGL Web ServicesCreating and calling an EGL Web Services

Page 285: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

285© 2009 IBM Corporation

Separation of Server-Side and Rich UI Elements – 10,000 Foot View

While RUIWidgets and RUIHandlers are the main focus for creating pages and widgets they are able to call out to EGL Programs, Libraries, and Services.

However, unlike EGL/JSF – where the vast majority of the work occurred on the server, in the Rich UI environment all EGL parts are generated to JavaScript.

This helps reinforce a clean separation between: Server-Side (business logic/data access) Client-Side (U.I. elements)

Business Logic deployed as Web Services EGL Generated RUI JavaScript running in a browser

Service calls tie the UI Logic to the server side business logic

Page 286: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

286© 2009 IBM Corporation

EGL/JSF – Run-Time Model – 1,000 Foot ViewEGL/JSF – Run-Time Model – 1,000 Foot View

In Server/Side EGL/JSF applicationsIn Server/Side EGL/JSF applications Your business logic accesses and processes data Which is bound to .JSF components and their underlying Java Classes Which – at run-time, emit (generate) HTML tags + data Which is sent back to the browser

Using EGL/JSF, almost everything results in Server-Side Run-Time cycles (relatively little happens in a standalone browser environment)

DataDataStoreStore

Java Java ClassesClasses

HTML HTML tagstagsDynamic Dynamic ContentContent

HTML HTML tagstagsDynamic Dynamic ContentContent

Rendered Rendered ininthethebrowserbrowserEmitsEmits

FormFormSubmitSubmit

Server-SideServer-Side Client-SideClient-Side

Page 287: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

287© 2009 IBM Corporation

EGL/Rich UI – Run-Time Model – 1,000 Foot ViewEGL/Rich UI – Run-Time Model – 1,000 Foot View

In EGL/Rich UI applicationsIn EGL/Rich UI applications Your Rich UI application – which runs in the browser, makes service calls to EGL (or non-

EGL) Server-Side functionality which access enterprise data or enterprise applications

Users interact with your Rich UI application. Users interact with your Rich UI application. Server-side components are cleanly de-coupled from Client/Side (Rich UI) application functionality. And because a RUIHandler consists of JavaScript running in the browser, there promises to be significant improvements in: Server-based application performanceServer-based application performance – due to functionality/cycles offloaded to the RUIHandler Browser-based dynamic processing capabilities and functionalityBrowser-based dynamic processing capabilities and functionality – ummm, simply due to Rich UI

DataDataStoreStore

Server-SideServer-SideApplication(s)Application(s)

RUIHandlerRUIHandlerApplicationApplication

GeneratedGeneratedJavaScript +JavaScript +HTMLHTML

RUIHandlerRUIHandlerApplicationApplication

GeneratedGeneratedJavaScript +JavaScript +HTMLHTML

Rendered in

thebrowser

Service Calls

JSONStringData

Server-SideServer-Side Client-SideClient-Side

Page 288: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

288© 2009 IBM Corporation

Rich UI Service Functionality – 500 Foot ViewRich UI Service Functionality – 500 Foot View

So, your Rich UI applications depend on web services for their business data I/O.

There are two categories of service: SOAP Web ServicesSOAP Web Services – data is transmitted through a standard WSDL (Web Service

Description Langue) file: http://en.wikipedia.org/wiki/Web_Services_Description_Language

You access the WSDL through an EGL interface– Recall that you learned how to do this in your previous EGL classes or work.

Note that these Web Services can be:– EGL Java Web Services– CICS Web Services – System z– RPG Web Services – System i– 3rd Party Web Services – any language, any computing platform

REST Web ServicesREST Web Services – data is typically transmitted in JSON (JavaScript Object Notation) strings: http://en.wikipedia.org/wiki/Representational_State_Transfer

In this section we will focus on accessing SOAP Web Services through WSDL files

We will cover REST services and JSON string handling in an appendix to this course

Page 289: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

289© 2009 IBM Corporation

Rich UI Service Functionality – 100 Foot ViewRich UI Service Functionality – 100 Foot View

What you will have to do before calling services from your EGL Rich UI applications:

1. Create or access the WSDL If using EGL/Java, follow the steps in the EGL Foundation Tutorial to:

– Ensure that your web (not Rich UI, web server) project’s build file descriptor has the proper options set.– Create or code a Service part– Define the Service part to the Services Descriptor– Generate the WSDL

If using CICS there are tools in RDz, and Service Flow Modeler to create WSDL files

If using RPG there are automated facilities in RDi-SOA for creating EGL services (specifically, an EGL Web Services Wizard)

If using a 3rd Party Web Service:– Access the WSDL – Ensure that all elements of the WSDL are supported by both the target platform and by EGL

– The toolset will produce validation warnings and diagnostics if there are problems at Generate time

2. Import the WSDL into your Rich UI project and create the EGL Client Interface

3. (Optionally) Test the WSDL using the Web Services Explorer facility

4. Create the service calls from your EGL RUIWidget(s) – next slide

Page 290: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

290© 2009 IBM Corporation

Rich UI Service Statements – 10 Foot ViewRich UI Service Statements – 10 Foot View

There are four elements in the statement construction pattern to call a Web Service from an EGL Rich UI view:1. Declare the service variable2. Code the service call – which can be broken down further:

1.1. CallCall to the service.function(…)

2. The parameter listparameter list3. The service callbackcallback reference

4. The service exception handling functionexception handling function reference

3. Code the Web Service Callback Function4. Code the Web Service exception-handling function

Note these elements in this simple example

1.2.1.

2.2.

2.4.2.3.

3.

4.

Dude…what’s a “Callback Function”?

Hang on –we’ll be getting to that shortly.

Page 291: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

291© 2009 IBM Corporation

Rich UI Service Call Statement – 1 Foot ViewRich UI Service Call Statement – 1 Foot View

call serviceName.operationName(argumentList)call serviceName.operationName(argumentList)returning to myCallbackFunction returning to myCallbackFunction onException myExceptionHandler {timeOut = milliseconds};onException myExceptionHandler {timeOut = milliseconds};

• serviceNameserviceName• Name of a variable based on an Interface part (see previous section on creating an EGL interface from a WSDL

•operationNameoperationName• Name of the Interface part’s function

• argumentListargumentList• List of arguments, each separated from the next by a comma.

• myCallbackFunctionmyCallbackFunction• Name of a callback function that is available to the call statement. In most cases, the function is in the same Rich UI handler or in a library.

• myExceptionHandlerFunctionmyExceptionHandlerFunction (Optional) • Name of a exception handler that is available to the call statement. In most cases, the exception handler is in the same Rich UI handler or in a library.

Most of the above does not represent “new learning stuff”, except for possibly the “callback function”. So let’s dig into that a little more…

Page 292: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

292© 2009 IBM Corporation

function callBackFunc(Positional Parameter List)function callBackFunc(Positional Parameter List)//assign data returned from service call to Rich UI fields //assign data returned from service call to Rich UI fields //(optionally) do other processing//(optionally) do other processing

endend

• Positional Parameter ListPositional Parameter List• You will need to define one argument for each out or inout parameter in the Web Service function call associated with the Callback

• Including one for the return argument• These parameters must “datatype match” – positionally with the Call statements arguments to the Web Service

function serviceExceptionFunc(excp anyException in)function serviceExceptionFunc(excp anyException in)//Parse the excp fields //Parse the excp fields //Take action depending on the what has happened//Take action depending on the what has happened

endend

ExampleExample

(Code in Slide ***Notes)

Callback and onException Functions – Code Callback and onException Functions – Code (still 1 foot view)

call WebService.Function (arg1, arg2, arg3) returning to callBackFunction… call WebService.Function (arg1, arg2, arg3) returning to callBackFunction…

Function callBackFunction (arg1Type, arg2Type, arg3Type, returnType)Function callBackFunction (arg1Type, arg2Type, arg3Type, returnType) //assuming the Web Service has a returns(dataType) argument//assuming the Web Service has a returns(dataType) argument

call WebService.Function (arg1, arg2, arg3) returning to callBackFunction… call WebService.Function (arg1, arg2, arg3) returning to callBackFunction…

Function callBackFunction (arg1Type, arg2Type, arg3Type, returnType)Function callBackFunction (arg1Type, arg2Type, arg3Type, returnType) //assuming the Web Service has a returns(dataType) argument//assuming the Web Service has a returns(dataType) argument

Page 293: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

293© 2009 IBM Corporation

RUI Programming Model – “Callback” Functions

EGL functions that respond to asynchronous and preemptive browser or system events (a system event example might be the return of control from a Service call to a RUIHandler) are self-contained – that is, they are modular and independent or isolated packets of code. The antithesis of monolithic programs.

This event-driven software model requires that you managemanage – programmatically direct – the return of control from an event to the appropriate EGL Function that will handle the event. Such a function might:

Move data from a service-based data access call to an array that populates a Grid Validate user data entry – returning appropriate error messages Redirect to some other functionality, inside or out of your RUIHandler, etc.

The common name for this kind of function is: ““Callback” FunctionCallback” Function You can think of a Callback Function simply as an event handler that is called

by the event dispatcher in response to an asynchronous event

When a browser eventbrowser event invokes one of your EGL functions you specify (associate) the Callback function to your EGL logic Function through the through the Events tab

When a system eventsystem event (i.e. a return from a Service call) invokes one of your EGL Functions, in order for it to do so you must have specified the name of the EGL Function in the returning toreturning to modifier of the Service callcall statement

Page 294: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

294© 2009 IBM Corporation

Traditional vs. Event-Driven Programming Models

TraditionalTraditionalProcedural Run-time modelProcedural Run-time model

(Next Sequential Instruction programming idiom)(Next Sequential Instruction programming idiom)

Do processingDo processing……

Call a service Call a service

Wait … Wait … Wait …Wait …Wait …Wait …Wait …Wait …

Service call returns! Service call returns! ……

Do more processingDo more processing……

Do processingDo processing……

Call a service Call a service (Specify a “Callback” Function)(Specify a “Callback” Function)

……

Do more processingDo more processing……

Service call returns! Service call returns! (“Callback” Function (“Callback” Function is automatically invoked)is automatically invoked)

……

Do more processingDo more processing

……

Event-DrivenEvent-DrivenRich UI Run-time modelRich UI Run-time model

(Modular, independent functions)(Modular, independent functions)What does the above have to do with events?

See next slide for yet more details…

What does the above have to do with events?

See next slide for yet more details…

Page 295: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

295© 2009 IBM Corporation

Service Calls (and Callbacks) on the “Event Pipeline”

Do InitialProcessingDo InitialProcessing

Render RUI view in the browserRender RUI view in the browser

EventEvent - onClick - onClick captured incaptured in RUIHandler, handled RUIHandler, handled as an EGL Functionas an EGL Function

Call a service Call a service (note that calling a (note that calling a service does NOT pre-req. a service does NOT pre-req. a browser/user event)browser/user event)

EventEvent - Service call returnsService call returns(EGL “Callback” Function (EGL “Callback” Function automatically invoked)automatically invoked)

Do something with data fromDo something with data fromthe service callthe service call

User clicks a button

Events in the Events in the BrowserBrowser

RUI Handler (EGL) codeRUI Handler (EGL) code

DatabaseDatabase

Enterprise DataEnterprise Data

Control immediately returns to the browser

EventEventPipelinePipeline

Page 296: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

296© 2009 IBM Corporation

Your First Rich UI Service Call WorkshopYour First Rich UI Service Call Workshop

Time for a lab! Let’s see how much of the previous material sunk in. The only way to find out? Develop a Service Call from scratch, and run it from a Rich UI application.

You will use an existing WSDL – so at the risk or repeating ourselves, the steps are:

1. Access the WSDL

2. Import the WSDL into your Rich UI project and create the EGL Client Interface

3. (Optionally) Test the WSDL using the Web Services Explorer facility Well no … we will skip this step for now

4. Create the service calls from your EGL RUIHandler and Preview (test)

onClick EventRich UICall ServicePassing: - City Name - Country

CallBack Function text returned

onClick EventRich UICall ServicePassing: - City Name - Country

CallBack Function text returned

Return CurrentReturn CurrentWeather Weather

informationinformation

In an XML stringIn an XML string

Return CurrentReturn CurrentWeather Weather

informationinformation

In an XML stringIn an XML string

Page 297: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

297© 2009 IBM Corporation

Access the 3rd Party WSDL Open a browser and go to www.xmethods.net

When the page loads, click View the Full List

When the Full List is done loading, do a search for Global Weather

Find and click on the following result:

Page 298: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

298© 2009 IBM Corporation

Save the 3rd Party .WSDL File to Your Project At the next page, right-click over the WSDL file and select Save Link As…

From there, change the file type to All Files and add the .wsdl extension to the File Name. Hint: Make sure to save the WSDL in a location where you can find it.

Return to the EGL Rich UI editor and Right-click over the EGLSource folder. Create a new package called wsdl

Find &copy the globalWeather.wsdl file you just saved, and paste it into the wsdl package

Page 299: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

299© 2009 IBM Corporation

Generate the EGL Client Interface for the Service Your project should now look as follows!

Right-click over the WSDL file and select EGL Services Create EGL Client Interface…

Page 300: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

300© 2009 IBM Corporation

Review the Generated Interface Code A wizard will pop-up. Click Finish You should now have a new package and EGL File automatically created for you.

At this point, from Project Explorer: Select your EGLRichUI projectSelect your EGLRichUI project Right-click and select GenerateRight-click and select Generate

The file should look like this… (note the functions and string parameters)The file should look like this… (note the functions and string parameters)

Page 301: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

301© 2009 IBM Corporation

Create the RUIHandler to Call the Service Now, right click over the NET.weberviceX.www package and create a new EGL

Rich UI Handler File. Name the file WeatherWeather

Next, code the following UI Components! Copy/paste code available in the notes

Page 302: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

302© 2009 IBM Corporation

Layout the UI for the RUIHandler (to call the Service)

Next, add the layoutBox and resultString to the RUIHandler’s initialUI property.

Save the file, you should now have the following output.

Next, let’s add an onClick event to the Button This event will call the service and store the result in resultString

To call the service, we will simply create a variable of the Service Interface (take a look at the code that was generated for us if you’re confused) From there we can use a basic call statement to call the service function, and then specify a

callback. The callback is a function that will execute when a result is returned from the service call.

The input parameter for the callback function must match what the service returns

Page 303: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

303© 2009 IBM Corporation

Code the Calling, Callback and onException Functions Code (or use Copy/Paste code from the Slide ***Notes) the following three functions

in the RUIHandler The function fired off by the onClick event

This function will make the actual service call to the weather service The Callback function for the service

That assigns the value returned (if any) The onException function – that uses some advanced EGL string “casting” (redefining the

excp record on the fly) to format and display run-time error messages

Page 304: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

304© 2009 IBM Corporation

Preview and Test Give the page a shot (note that only major international cities are available – i.e. Paris, London, NY, Pittsburgh,

Raleigh, etc. Missing are places like Glen Rock, Wake Forest, Coventry, etc.)

As you shall see, this particular service returns an XML string into the .text.text property of the resultStringresultString RUIWidget

Page 305: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

305© 2009 IBM Corporation

Your Second Rich UI Service Call WorkshopYour Second Rich UI Service Call Workshop

So now, we’ll really find out how much of the previous material sunk in. It’s time for you to develop a Web Services call from a Rich UI application without being given all the explicit steps. Again, from the www.xmethods.net site:

Select the Full List and do a find on: AmortizationAmortization Copy down the Amortization Calculator’s wsdl (save it in your \wsdl\ folder as a .wsdl.wsdl file

Use the tooling to generate an interface to the WSDL and call the service: Generate the EGL Services > Create EGL Client Interface – and

note the code produced takes parameters all of type: float

Create a new RUIHandler named: amortizationCalc amortizationCalc

And either on your own – or using the EGL RUIHandler code in the notes page, define variables and functionality for calling the Web Service

Page 306: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

306© 2009 IBM Corporation

Call a Mainframe CICS/Web Service So – if we’re to believe the hype surrounding Web Services then how different

or how much harder) would it be to call a mainframe, CICS/COBOL web service? Answer: Not hard/not different. Skeptical? (fair enough…let’s see try one on for size)

In the com.ibm.egl.education.widgets project, there’s a WSDL file named: EPSCSMR.wsdl This WSDL was created by Regi Barosa/IBM using RDz tooling. It calls a CICS/COBOL subroutine to

(yes, once again!) calculate mortgage rates. This services runs on an IBM mainframe in Dallas, TX

From the above, what are the inputs ? How could you figure out the data types (hint – use the WSDL editor’s Source mode)

Page 307: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

307© 2009 IBM Corporation

Call a Mainframe CICS/Web Service – 1 of 5 Copy the EPSCSMR.wsdl file, from the education project to your EGLRichUI project – and put it in the \\

WebContent\wsdl\WebContent\wsdl\ folder. - As you’ve done twice now, use the tooling to create the EGL Interfaces for the EPSCSMR.wsdl file. - Note that you will get two separate source files:

* EPSCSMRTIInterace – the inputs needed to call the CICS Web Service on the host* EPSCSMRTOInterface – essentially the output or returned data from the CICS/COBOL

program

The EGL Rich UI coding pattern will be: Call the CICS/COBOL Service with the inputs Return to the Callback Function from the CICS/COBOL Service receiving the outputs as parameters

Page 308: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

308© 2009 IBM Corporation

Call a Mainframe CICS/Web Service – 2 of 5 Using your prodigious EGL Rich UI programming skills, create the

following simple U.I. in your \sandbox\ package: We named ours: regisServiceregisService – but you can pick any name you like

And … well…okay (you twisted our arms) Since there’s really nothing new in the U.I. use the Copy/Paste code

in the Slide ***Notes***Notes

Page 309: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

309© 2009 IBM Corporation

Call a Mainframe CICS/Web Service – 3 of 5 Here’s what the onClick function should look like.

As before, you can develop this by hand, or use the Copy/Paste code in the Slide ***Notes***Notes

Is there anything new in these statements? Not really. A useful technique though, is to change the button text and disable it while the Web Service is off being accessed.

Also the Input variable of type: DFHCOMMAREA has an import for it (see prior Slide ***Notes)

Page 310: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

310© 2009 IBM Corporation

Call a Mainframe CICS/Web Service – 4 of 5 Here is the CallBack and onException function. The only new coding construct herein is the

fully-qualified parameter type on: displayResults_cics

This coding pattern is necessary because there’s already a record named: DFHCOMMAREA that’s being referenced through an import statement

You can copy this code from the Slide ***Notes (it’s probably easier than typing it all in)

Page 311: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

311© 2009 IBM Corporation

Call a Mainframe CICS/Web Service – 5 of 5 Preview the RUIHandler

Enter values such as those shown in this screen capture

And click the button. The actual functionality is running on an IBM mainframe in Dallas, TX

Try passing different values in to the Web Service for: Amount Rate Term

Note the response time and speedy performance (not bad for an old mainframe)

Now it’s time to move on, and work with EGL-generated Web Services. We’ll start by reviewing the steps needed to create a Web Service then generate the WSDL, then we’ll discuss using the WSDL in your Rich UI project.

Page 312: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

312© 2009 IBM Corporation

Review of EGL Services – Steps for Creating and Consuming Web ServicesHere are the steps you will take to create a Web Service – from your Web or Application server project:

1. Start Tomcat – or WebSphereWebSphere (see ***Notes***Notes)2. Customize your project’s Build File3. Create and generate a Web Service

Code the service Generate the service

4. Generate the WSDL for your Service – may need to customize the service port (end point)5. Test the WSDL Using Web Services Explorer

6. Consume the Web Service (If using a 3rd Party WSDL) Import or copy the EGL-generated WSDL to your Client/Project Generate or create the EGL Client Interface(s) from the WSDL In the EGL Rich UI process - code a variable of <serviceName> type Code the call to the ServiceVar.function – passing parameters and returning to a Callback function

(From the Servers Tab in the Web Perspective) Start TomcatStart Tomcat or start WebSphere or start WebSphere

Note that if you don’t have a server yet defined for your project, create one before continuingNote that if you don’t have a server yet defined for your project, create one before continuing

Page 313: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

313© 2009 IBM Corporation

(Review) Customize Your Project’s Build-File – and Generate Your Project

You need to select the serverType you will be publishing the Web You need to select the serverType you will be publishing the Web Server toServer to Open EGLWeb.eglbld Un-check Show only specified options Scroll down to find the serverType option Use the combo-box to select the serverType for your

project WEBSPHERE TOMCAT

Select the serverType Select the serverType

Page 314: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

314© 2009 IBM Corporation

(Review) Create a new EGL Web Service

In your server-side project (i.e. NOTNOT in your Rich UI project) you will create your custom EGL Web Services - typically (although not necessarily) in a package named something like \\services\services\ under \EGLSource\\EGLSource\

2. Check: Create as web service

See See ***Notes***Notes

1. Create a New > Service

Page 315: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

315© 2009 IBM Corporation

(Review) Create a new EGL Web Service – continuedRecall that EGL Services are simply EGL business logic parts. As such they allow full programming access to the complete EGL language. From EGL Services you can:

Access data: DB2, Informix, DL/I, VSAM/QSAM, MQ, CSV (Excel spreadsheet) files – and other sequential files

Access existing EGL applications and business logic Access mainframe functionality:

System z – COBOL/CICS, IMS TM (MPP/QBMP) programs System i – RPG, CL or COBOL programs

– The above COBOL programs can be native (hand-coded) or EGL-generated

Access Java applications an frameworks Access C/C++ .DLLs and applications…etc…

Here’s a sample Service

After ensuring that your project settings are complete:

(From Project Explorer) Generate your EGLWeb ProjectGenerate your EGLWeb Project

Page 316: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

316© 2009 IBM Corporation

(Review) Generate the WSDL for Your Web Service

You will then Generate the Web service - Generate the Web service - From Project Explorer

After successfully generating the WSDL, you can open it in the Content Area – it’s located under: \WebContent\WEB-INF\wsdl\\WebContent\WEB-INF\wsdl\

Optionally, you can test the Web Service

But before continuing, you may need to customize the WSDL “end-points” – the port# for the WSDL address. Note: An “end-point” is the URL (ping-able web address) of where your application server is “listening” for incoming calls to your Web Service.

***Notes***Notes

Page 317: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

317© 2009 IBM Corporation

(Review) Test the Web Service – Interactively – 1 of 2

RBD contains an interactive Web Services test facility called the Web Services Explorer.

You can use this tool to test your Web Service functionality effectively, before embedding calls to it from your service client.

You invoke the Web Services Explorer by:

Right-Clicking over the generated .wsdl file Selecting: Test with Web Services Explorer

Page 318: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

318© 2009 IBM Corporation

(Review) Test the Web Service – Interactively – 2 of 2 This opens the Web Services

Explorer – and opens your Service in the Navigator

All of the services functions are exposed as Actions for you to test.

You will fill in parameter values, press Go and view the results in the Status view

*** Your Application *** Your Application Server must be still Server must be still be startedbe started

Page 319: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

319© 2009 IBM Corporation

(From your Rich UI Project) Create an EGL Client Interface to the WSDL

From Project Explorer in your EGL Rich UI project you will: Right-clickRight-click over the WSDL Select: EGL Services > Create EGL Client Interface…> Create EGL Client Interface…

Page 320: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

320© 2009 IBM Corporation

(Review) Create an EGL Client Interface to the WSDL

If a duplicate EGL part name exists, you will need to rename the EGL source and interface files The EGL source file name The Interface name

Note – that this will be the exception, not the rule in calling services from EGL Rich UI

Page 321: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

321© 2009 IBM Corporation

Create the Web ServiceCreate the Web Service Time to roll up the sleeves and create

some of our own services: From your EGLWeb project:

Start your web or application server Create a new Service part in the \

EGLSource\services\ folder, named: RUIServicesRUIServices

Be sure to check: Be sure to check: Create as WEB (SOAP) service

If you’re prompted to Deploy the EGL Service? Allow the tooling to generate and

deploy the Service to your application server before continuing

Page 322: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

322© 2009 IBM Corporation

Create the EGL Login Function in the ServiceCreate the EGL Login Function in the Service Here is the code for Logging in

We’re using the old Siteuser table that has USER_ID and Pass_Word columns

You can either code this from scratch, using explicit SQL, or copy/paste this function from the Slide ***Notes

When you’ve saved and all syntax errors are cleaned up: From Project Explorer,

GenerateGenerate the entire EGLWeb project

This will create a wsdl folder under \WebContent\WEB-INF\ With your new RUIServices.wsdl file

in it

Page 323: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

323© 2009 IBM Corporation

(OPTIONAL) Test the Web Service using Web Services Explorer Test the Web Service using Web Services Explorer

Before proceeding with additional UI work (and potentially complicating your testing process) – From Project Explorer: Right-click over the RUIServices.wsdlRight-click over the RUIServices.wsdl Select Web Services > Test with WebServices ExplorerSelect Web Services > Test with WebServices Explorer Select loginService – and type values for: uid and pwd - click Go Select loginService – and type values for: uid and pwd - click Go In the Status area, verify a (true) return code from the service callIn the Status area, verify a (true) return code from the service call

Note that you may need to restart your application server, in order to publish and run

Page 324: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

324© 2009 IBM Corporation

Create the EGL Client InterfaceCreate the EGL Client Interface So, now we’re ready to do unto the EGL Web Service, as we did unto the 3rd Party Services.

From Project Explorer Copy the wsdl file: from EGLWeb project to the EGLRichUI project. Put it in a \WebContent\wsdl\\WebContent\wsdl\ folder

Note that you may have to create the new Note that you may have to create the new \wsdl\\wsdl\ folder under folder under \WebContent\\WebContent\ Right-click over the wsdl and select:

EGL Services > Create EGL Client Interface…

GenerateGenerate the EGLRichUIEGLRichUI project

Page 325: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

325© 2009 IBM Corporation

Call the Web Service from your Login ViewCall the Web Service from your Login View

So – let’s see how we did? Open your loginPage.egl, and modify the existing business logic. It’s probably best at this

point, to copy/paste the code in from the Slide ***Notes

Here’s the finished product. What’s new?

Answer: Nothing

Which rocks.

How about one more?

The USERID field The PASSWORD field

Page 326: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

326© 2009 IBM Corporation

Create a Web Service to Populate a Rich UI dataGrid So, let’s combine the dataGrid you’ve been learning about with Services. This workshop will

show you an end-to-end process where you: Create a Web Service that returns an array of customer records, based on a search argument Create a RUIHandler that:

Calls the service – passing a user-entered-partial string Returning (in the Callback function) all of the rows found into the dataGrid

The visual representation of the run-time architecture is shown in this picture…

EGLDerbyR7EGLDerbyR7

Call ServiceCall ServiceFunctionFunction

onClick Event

RUIHandler

EGLWeb ProjectEGLWeb Project

ServiceService

WebSphereWebSphereTomcatTomcat

ServiceService

CallbackCallbackFunctionFunction

RUIHandler

Browser

Browser

Server

Server

Page 327: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

327© 2009 IBM Corporation

Create the Web ServiceCreate the Web Service Same steps as before

From your EGLWeb project: Make sure that your web or application server is started Create a new Service part in the \EGLSource\services\ folder, named:

customerServicescustomerServices

Be sure to check: Be sure to check: Create as WEB (SOAP) service

Here is the code for accessing customer table data

You can either code this from scratch, using explicit SQL, or copy/paste this function from the Slide ***NotesSlide ***Notes

When you’ve saved and all syntax errors are cleaned up:

From Project Explorer,

GenerateGenerate the entire EGLWeb project

This will create a wsdl folder under \WebContent\WEB-INF\

containing your new customerServices.wsdl file

Page 328: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

328© 2009 IBM Corporation

(OPTIONAL) Test the Web Service using Web Services Explorer Test the Web Service using Web Services Explorer

As before, you may want to test with the Web Services Explorer

From Project Explorer: Right-click over the customerServices.wsdlRight-click over the customerServices.wsdl Select Web Services > Test with WebServices ExplorerSelect Web Services > Test with WebServices Explorer Select getCustomerSearch – and type values for Select getCustomerSearch – and type values for

custString: custString: SS Click Go Click Go In the Status area, verify a (true) return code from the In the Status area, verify a (true) return code from the

service callservice call Note that you may need to restart your application server, in

order to publish and run Optionally – you might want to test getOneCustomerSearchOptionally – you might want to test getOneCustomerSearch

From Project Explorer: Right-click over the customerServices.wsdlRight-click over the customerServices.wsdl Select Web Services > Test with WebServices ExplorerSelect Web Services > Test with WebServices Explorer Select getCustomerSearch – and type values for Select getCustomerSearch – and type values for

custString: custString: SS Click Go Click Go In the Status area, verify a (true) return code from the In the Status area, verify a (true) return code from the

service callservice call Note that you may need to restart your application server, in

order to publish and run Optionally – you might want to test getOneCustomerSearchOptionally – you might want to test getOneCustomerSearch

Page 329: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

329© 2009 IBM Corporation

Create the EGL Client InterfaceCreate the EGL Client Interface

Copy the wsdl file: from EGLWeb to EGLRich UI – and put it in the \WebContent\wsdl\ folder Right-click over the wsdl and select: EGL Services > Create EGL Client Interface… GenerateGenerate the EGLRichUIEGLRichUI project

Page 330: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

330© 2009 IBM Corporation

Call the Web Service from your Login ViewCall the Web Service from your Login View

So – it’s time to call customerServicescustomerServices from a RUIHandler In the \mySamplesmySamples\ folder, Create a new RUIHandler named: customerSearchGridcustomerSearchGrid Copy/paste the code in from the Slide ***Notes***Notes – and overlay the boilerplate EGL source

- Note the various widgets

- Note especially the code that calls the Web Service

Save and runSave and run

Page 331: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

331© 2009 IBM Corporation

OPTIONAL LABS – dataGrids and Web Services

1. 1. In customerSearchGrid: Uncomment processGrid – note that this is a custom behavior, for grid widgets. It allows you to

substitute widgets for the defaults in rows. Note the reference to this in the widget declaration

2. 2. Calling the getOneCustomerSearch Web Service, populate

a RUIHandler like this

Notes: The UI is not that important …but… Copy/Paste code is found in the next slide You will need to make sure that you import the correct version

of the customer record – to match the type referenced

Page 332: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

332© 2009 IBM Corporation

OPTIONAL LABS – dataGrids and Web Services

The solution Copy/Paste code is in the slide notes. Note the following run-time elements and events…

EGLDerbyR7EGLDerbyR7

Call ServiceCall ServiceFunctionFunction

onClick Event

RUIHandler

EGLWeb ProjectEGLWeb Project

ServiceService

WebSphereWebSphereTomcatTomcat

ServiceService

CallbackCallbackFunctionFunction

RUIHandler

Page 333: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

333© 2009 IBM Corporation

OPTIONAL LABS – Code Free Workshop – Get Orders for a Customer – 1 of 6

Copy/Paste code is in the slide notes (function name mis-spelling and all). Note the following run-time elements and events…

Create a new Web Service in your EGLWeb project

This service should have a function that takes in an integer – representing a customer_ID and returns an array of order records for that customer

Be sure to:Be sure to: Generate your EGLWeb projectGenerate your EGLWeb project Restart your app-serverRestart your app-server

Page 334: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

334© 2009 IBM Corporation

OPTIONAL LABS – Code Free Workshop – Get Orders for a Customer – 2 of 6

Test your new Web Service with the Web Services Explorer facility

Page 335: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

335© 2009 IBM Corporation

OPTIONAL LABS – Code Free Workshop – Get Orders for a Customer – 3 of 6

Copy the WSDL from your EGLWeb to your EGLRichUI project, and generate an EGL Client Interface…. Then – from Project Explorer, Generate your EGLRich UI Project

Page 336: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

336© 2009 IBM Corporation

OPTIONAL LABS – Code Free Workshop – Get Orders for a Customer – 4 of 6

From PagingGridBasics.egl: Copy the existing myPagingGrid pagingGridmyPagingGrid pagingGrid specifications and paste them inside the

file Make the modifications to the: columns and gridSelector shown below

Note: Type VERY VERY carefully

Page 337: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

337© 2009 IBM Corporation

OPTIONAL LABS – Code Free Workshop – Get Orders for a Customer – 5 of 6

Still from PagingGridBasics.egl: Add the functions, and make the modifications shown below

Once again, type VERY VERY carefully

Okay, okay – you win. This slide contains the finished code in the ***Notes

Page 338: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

338© 2009 IBM Corporation

OPTIONAL LABS – Code Free Workshop – Get Orders for a Customer – 6 of 6

Preview and test the RUIHandler

Page 339: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

®

IBM Software Group

© 2009 IBM Corporation

Creating an end-to-end RESTful Service

Chris Laffra

Page 340: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

340© 2009 IBM Corporation

Create an End-to-end EGL Create an End-to-end EGL Web Service using REST onlyWeb Service using REST only From your EGLWeb project:

Create a new Service part in the \EGLSource\services\ folder, named: RUIRestServicesRUIRestServices

Be sure to check: Be sure to check: Create as WEB (REST) service

Here is the service code You can either code this from

scratch, or copy/paste this function from the Slide ***Notes

When you’ve saved and all syntax errors are cleaned up: From Project Explorer,

GenerateGenerate the entire EGLWeb project

If you have not deployed your service yet, do it now by running it on the Tomcat server you selected before:

Page 341: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

341© 2009 IBM Corporation

Consume an End-to-end EGL Consume an End-to-end EGL Web Service using REST onlyWeb Service using REST only In the Project Explorer, right-mouse click your service and say:

EGL Services Extract Interface… In the wizard, select the EGLSource

folder in the RUI Project

Copy the RUI code fromthe Slide ***Notes

All EGL REST services use this pattern: http://<Server>:<PortNumber>/<ProjectName>/restservices/<ServiceName>

Note: If you are seeing errors, make sure to Generate your service project Run your service on Tomcat Verify that Tomcat is using port 8080

You have 2 projects: A service project that is deployed on TOMCAT A RUI project that invokes the service using an interface

Page 342: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

342© 2009 IBM Corporation

Course

Units:

Rich UI Inter-Program Rich UI Inter-Program CommunicationCommunication

Inter-Program CommunicationInter-Program Communication Invoking functions in other Widgets and RUIHandlers

InfoBus

Comprehensive Workshop

The Web 2.0 Development Process with Rich UI

The workshop

Appendix

Page 343: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

343© 2009 IBM Corporation

RUI Application Run-Time Architecture – 10,000 Foot View

RUI “Application”

RUI Handler RUI Handler

Independent entitiesIndependent entities

EGL Server Side Processes

Services

Libraries Programs

Enterprise ApplicationsEnterprise Applications

DatabasesDatabases

MQMQ

External FilesExternal Files

DL/IDL/I

RUIWidget(RUIHandler)

RUI LibraryUI Logic, Service Calls

RUI LibraryUI Logic, Service Calls

RUI Handler “embedded part”

JSF Application

RUIWidget(RUIHandler)

Forwards to

Invokes

InvokesComposed of

Accesses Server Side Data

ExternalTypeInvoke existing JavaScript

JavaJava……or…or…RPGRPG……or…or…COBOLCOBOL

SQL or otherSQL or otherFile I/OFile I/O

Composed ofComposed of

Calls function inCalls function in

Invokes

Page 344: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

344© 2009 IBM Corporation

Rich UI Application = RUIHandler + RUIWidgets – Review

A scaled-down model of an EGL Rich UI application might be a single RUIHandler – composed of several RUIWidgets.

Each RUIWidget is composed of one-to-many elementary widgets (similar to a record / group fields and elementary fields)

Both RUIHandlers and RUIWidgets have: Properties Behaviors

All of the properties and behaviors: Are exposed in EGL Rich UI model Can be specified (programmed) according to the

requirements of your application

From this example – can you find the following elements

– RUIHandlerRUIHandler, which is composed of: A text fieldA text field (an elementary) RUI Widget as header text (in blue) RUIWidget #1RUIWidget #1 – which is composed of:

Eight input fields, Eight Text fields, Two buttons, Eight input fields, Eight Text fields, Two buttons,

RUIWidget #2RUIWidget #2 – a Tab Control RUIWidget which is composed of: An Employee List RUIWidgetAn Employee List RUIWidget Three other tabs – which contain additional RUIWidgets (within the tabs)Three other tabs – which contain additional RUIWidgets (within the tabs)

Page 345: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

345© 2009 IBM Corporation

RUIHandler + RUIWidgets – Properties/Function Reference-abilityFrom any RUIHandler:

You can add any RUIWidget or RUIHandler to the main/parent RUIHandler as a variable You can access and manipulate the variable RUIWidget’s/RUIHandler’s public properties with carte’ blanche. And you can also invoke the added RUIWidget’s/RUIHandler’s public functions through either: Direct calls, Delegates or using a Rich

UI messaging system known as the InfoBusInfoBus You would use Direct Calls when the functionality in question was tightly-coupled You would use the InfoBus when the functionality in question was loosely-coupled (i.e. when for example you were creating Web 2.0 “mash-up” applications)

myRUIHandlermyRUIHandler

WidgetVariableWidgetVariable {Declared access to Properties} {Declared access to Properties}……Can manipulate non-private Can manipulate non-private WidgetVariableWidgetVariable properties and can invoke non-private properties and can invoke non-private WidgetVariableWidgetVariable functions using EGL Rich UI statements functions using EGL Rich UI statements……

SomeOtherRUIHandlerSomeOtherRUIHandler//Functions//Functions……Can manipulate non-private Can manipulate non-private WidgetVariableWidgetVariable properties and can invoke non-private properties and can invoke non-private WidgetVariableWidgetVariable functions using EGL Rich UI statements functions using EGL Rich UI statements……

Can use either the InfoBus or direct calls to invoke

a function in SomeOtherRuiHandlera function in SomeOtherRuiHandler

BestBestPracticePracticeAdviceAdvice

BestBestPracticePracticeAdviceAdvice

Page 346: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

346© 2009 IBM Corporation

Workshop – RUIHandler/RUIWidgets Properties Reference-abilityTo understand how easy it is to access and manipulate Widget properties from a RUIhandler do the following:

From: \mySamplesmySamples\ create a new, RUIHandler named: embeddedRUIWidgetembeddedRUIWidget Replace the boiler-plate EGL code, with the Slide ***Notes statements Study the statements – and note the use of the .dot syntax to reference widget variable properties SaveSave PreviewPreview Click the buttonClick the button

So – that’s how easy it is to extend RUIWidgets and their properties through their use (and reuse) in custom RUIHandlers. Now let’s look at calling functions in RUIWidgets.

Page 347: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

347© 2009 IBM Corporation

Workshop – RUIHandler/RUIWidgets Invoking FunctionsTo understand how easy it is to invoke functions in a Widget variable from a RUIhandler do the following:

Edit the EGL source in: embeddedRUIWidgetembeddedRUIWidget Add the code shown here in the screen capture:

Note that some of the functions have been collapsed in the source view

SaveSave PreviewPreview Click the buttonClick the button

So – that’s how easy it is to extend RUIWidgets, setting their properties and calling their functions from custom RUIHandlers. Now let’s look at calling functions using the InfoBus

Page 348: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

348© 2009 IBM Corporation

RUIHandlers and RUIWidgets – like the EGL Functions they contain – are independent programming units. As such when you wish to invoke an EGL function in RUIHandlerB – from an EGL function in RUIHandlerA you will actually post a message (fire an event) on an EGL-supplied run-time system called the “InfoBusInfoBus”.

This is how it works. “Called” RUIHandler – typically in a “start-up” function subscribessubscribes to (registers a listener for) an

InfoBus message identified by a string parameter value. This string is the event name.

The “Calling” RUIHandler – in the EGL function that will be used to invoke the function in RUIHandlerB “publishespublishes” a message to the InfoBus – with two parameters:

Hop on the InfoBus – Calling From one RUIHandler or RUIWidget to Another

InfoBus Message Identifier (event)InfoBus Message Identifier (event)

EGL Function to invoke …named in subscribe

EGL Function to invoke …named in subscribe

Parameter value passed in as the 2nd variableParameter value passed in as the 2nd variable

See ***Notes

InfoBus Message (event) Identifier(spelled exactly the same as the subscribe parameter)

InfoBus Message (event) Identifier(spelled exactly the same as the subscribe parameter)

EGL event handling Function. Note two ParametersEGL event handling Function. Note two Parameters

Page 349: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

349© 2009 IBM Corporation

InfoBus – One RUIHandler Invoking Functionality in Another

““Called” RUIHandler or RUIWidgetCalled” RUIHandler or RUIWidget……

StartupStartup EGL FunctionEGL Function

InfoBus.subscribe(“eventID”, functionName);InfoBus.subscribe(“eventID”, functionName);……

EGL Function named in subscribe(parm1, parm2)EGL Function named in subscribe(parm1, parm2)……

““Calling” RUIHandler or RUIWidgetCalling” RUIHandler or RUIWidget……

EGL Function invoked by some event that should EGL Function invoked by some event that should call/invoke the other RUIHandlercall/invoke the other RUIHandler

InfoBus.publish(“eventID”, variableValue);InfoBus.publish(“eventID”, variableValue);……… … other functionalityother functionality……

User clicks a button

InfoBusInfoBus

Subscribe to (listen for)

any event named: eventIDeventID

Subscribe to (listen for)

any event named: eventIDeventID

Publish a message for an event

named: eventIDeventID

The InfoBusInfoBus will find the namedlistener: “eventIDeventID” and will invokethe EGL function in the subscribesubscribe statement

Publish a message for an event

named: eventIDeventID

The InfoBusInfoBus will find the namedlistener: “eventIDeventID” and will invokethe EGL function in the subscribesubscribe statement

Page 350: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

350© 2009 IBM Corporation

Workshop – InfoBus – Simple Example – 1 of 3

To understand how easy it is to publish and subscribe on the InfoBus in order to call a Widget function from a RUIhandler (or in this case, another RUIHandler’s function from a RUIHanlder) do the following: From: \sandboxsandbox\ create a new, RUIHandler named: embeddedHandlerembeddedHandler Replace the boiler-plate EGL code, with the Slide ***Notes statements Study the statements – and note the use of the .dot syntax to reference widget variable properties Save

embeddedHandler is now

listening for an InfoBus message

mamed: “myInfoBusMsgmyInfoBusMsg” And when a

message with that name arrives, the

function: showPublishshowPublish is

invoked automatically

Page 351: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

351© 2009 IBM Corporation

Workshop – InfoBus – Simple Example – 2 of 3To understand how easy it is to publish and subscribe on the InfoBus in order to call a Widget function from a RUIhandler (or in this case, another RUIHandler’s function from a RUIHanlder) do the following:

From: \sandboxsandbox\ create a new, RUIHandler named: InfoBusTestInfoBusTest Replace the boiler-plate EGL code, with the Slide ***Notes statements Study the statements – and note the use of the .dot syntax to reference widget variable properties Save Preview Click the button

embeddedHandler is now

listening for an InfoBus message

mamed: “myInfoBusMsgmyInfoBusMsg”

Page 352: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

352© 2009 IBM Corporation

Workshop – Workshop – InfoBus – Simple Example – 3 of 3InfoBus – Simple Example – 3 of 3

Preview InfoBusTestPreview InfoBusTest

… and click the button

InfoBusInfoBusSystemSystemLibraryLibrary

Create widget instanceCreate widget instance

Page 353: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

353© 2009 IBM Corporation

Workshop – RUIHandler/RUIWidget Interoperability – Another Example – 1 of 4

Let’s apply our new Rich UI coding skills used to demonstrate the interoperability of Widgets to a more interesting use case – our tabFolder. We will demonstrate the following:

RUIHandler calling RUIWidget (variable): PropertiesProperties FunctionFunction

RUIWidget calling back to a RUIHandler (parent) using the InfoBus Note this is a somewhat complicated use case. If you have any questions on the reasons for any of the coding constructs behind the lab steps, ask your instructor to explain

Steps: Open the following files into the Content Area:

tabSample.egl, groupingSample.egl, htmlWidgets.egl, miscWidgets.egl, textFields.egl

Make the following changes to the existing code: In groupingSample.eglgroupingSample.egl – modify the changeLabel(…) function

By doing this, you are publishing an event to the InfoBus that will be picked up in tabSample, and used to open a different tab based on clicking the button in the RUIWidget

> SaveSave your changes to groupingSample.egl

Page 354: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

354© 2009 IBM Corporation

Workshop – RUIHandler/RUIWidget Interoperability – Another Example – 2 of 4

In tabSample:tabSample: Modify the initialization() function – as shown below

Add the callBackFunction(…) as shown here

Page 355: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

355© 2009 IBM Corporation

Workshop – RUIHandler/RUIWidget Interoperability – Another Example – 3 of 4 Still in tabSample:tabSample:

Modify the tabSelected(…) function – as shown below

Save your coding changes to all the .egl files

Page 356: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

356© 2009 IBM Corporation

Workshop – RUIHandler/RUIWidget Interoperability – Another Example – 4 of 4 Preview. Test the functionality by following this script:

When the view loads, click Grouping Sample – note the following:– tabSample changed the top box’s color to Moccasin

– And it changed the bottom fieldset’s label

Click the button in Grouping Sample– Text Fields will open – via an InfoBus message published in groupingSample that is subscribed in tabSample, and used to specify: tab.selected();

– It also changed the rollover graphic in Miscellaneous widget

Click the Miscellaneous Widgets tab (to verify this) Then click HTML Widgets (which changes the rollover graphic in Miscellaneous Widgets) So click the Miscellaneous Widgets tab again (to verify this)

Page 357: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

357© 2009 IBM Corporation

EGL Rich UI – Application Development “Best Practices” You will design your Rich UI applications as a collection of:

RUIHandlers – which are reusable components and contain: RUIWidgets – which represent widgets

Custom – may or may not be reusable IBM Supplied – example: Textarea, ListBox, Grid, DIV, etc. 3rd Party (Silverlight, Dojo, etc.) Calls to external JavaScript functionality

You will put multiple widgets together in a container widget: DIV, Box, floatLeft/floatRight, etc.

RUIHandlers and RUIWidgets may be: Visual Non-visual (i.e. calls to the business functionality in your system) Both

You will start the initial U.I. layout, by creating and testing your visual elements as RUIHandlers. Then change the RUIHandlers to become RUIWidgets, if you wish to use them in mash-ups or in the dynamic layout of your application in the browser

Example – hide/show U.I. elements based on business functional processes and rules

Page 358: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

358© 2009 IBM Corporation

Course

Units:

RBD/EGL DevelopmentRBD/EGL Development

EGL Rich UI – Model View Controller (MVC)EGL Rich UI – Model View Controller (MVC)

Page 359: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

359© 2009 IBM Corporation

Model/View/Controller – Development Pattern

The programming paradigm or pattern of Model-View-Controller has become somewhat mainstream in recent years.

A design utilizing this concept will be readable, maintainable, and scalable.

The concept however is most heavily centered on the JEE programming model. The roles of each are as follows: ModelModel – Encapsulates the information (data) and the methods to operate on that

information (business logic). ViewView – Presents the model (most often a dynamic web page such as a JSP). ControllerController – Processes user events and drives model and view updates.

To whit: Requests by the user are handled by the view and processed by the controller. The controller then accesses the business logic contained within the model. The model then passes data back to the view which dynamically builds a new UI

for the user.

The process is repeated over again (that’s why this is called a pattern)

Page 360: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

360© 2009 IBM Corporation

Model/View/Controller – Rich UI Implementation

In the realm of Rich UI, this particular use case doesn’t strictly apply. After all, Rich UI is strictly used to build dynamic UI’s!

You can think of Rich UI as building both the view and controller, which can access the model by making service calls.

However, the idea of Model-View-Controller is so good that we’ve enabled its concepts when programming in RUI.

So what do we do? We provide a framework that utilizes the

concept of MVC to simulate a traditional HTML form.

Note that support for some of the standard DataItem properties (like dateFormatting, and money types) is also done through Rich UI’s MVC

Page 361: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

361© 2009 IBM Corporation

Model/View/Controller

Perhaps this is one thing you have been missing when programming in Rich UI?

Wouldn’t you like the ability to submit an entire form which automatically validates itself!

Look no further than the MVC framework shipped with Rich UI The roles of each are as follows:

ModelModel – The underlying data accessed from within Rich UI (ex. could be a record or EGL variable)

ViewView – The widget displaying the data (ex. A TextField, CheckBox, etc) ControllerController – The bridge between displaying the data from the model, in the view. The

controller also provides a simple interface for validating the input.

Last but not least, the framework allows us to encompass all of this into a single form. That form can then be submitted and everything validated at once. Of course, different logic will be implemented by you for each case.

Page 362: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

362© 2009 IBM Corporation

Model/View/Controller

Let’s take a look at this functionality by doing a workshop.

Create a new package under the EGLRichUI project called mvc

Next, right-click over the mvc package and create a new Rich UI Library called ValidationMessages

Page 363: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

363© 2009 IBM Corporation

Model/View/Controller

Inside of the ValidationMessages library, copy/paste the code in the notes and replace any existing text in the file.

For now lets just skip the explanation of this file and come back to it Next, create a new file under WebContent properties called

ValidationMessages-en_US.properties

Page 364: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

364© 2009 IBM Corporation

Model/View/Controller

Now copy the text from the notes and paste it into the properties file we just created.

Next, create a new RUI Handler called EmployeeInfo under the mvc package.

Page 365: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

365© 2009 IBM Corporation

Model/View/Controller

Inside of the EmployeeInfo file, copy/paste the record in the notes below the RUI Handler

This record will function as the Model, or the data for our Rich UI Handler.

Notice how the model correlateswith the ValidationMessagesrecord we just created

Page 366: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

366© 2009 IBM Corporation

Model/View/Controller

So now that we have our model defined, lets go ahead and create the view portion of the implementation (reminder: a view is what will display the data)

It is only fitting that we create a widget to display each piece of data in the model. In doing so, you will add the following code to the RUI Handler.

Copy/Paste code is provided in the notes. Press: Ctrl/Shift/O – to bring in the missing import statements

Page 367: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

367© 2009 IBM Corporation

Model/View/Controller

We have now completed both the model and view portions of the MVC architecture. You may be wondering how the model and view are tied together, if so read-on! But first, lets create a variable of the Employee record in our RUI Handler

*** Important – be sure to select the MVC record for the import.

Now we will code the controller, which in turn will tie the model to the view Don’t worry, the syntax is the same as if we were creating a variable of a normal widget!

To the right is a sample implementation of a controller Notice that we are simply creating

a variable of type Controller The controller takes an

annotated property “@MVC” This property accepts a model and a view as parameters

Notice that the model is simply the data variable, and the view is simply the UI widget variable. Once again, press Ctrl/Shift/OCtrl/Shift/O

Page 368: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

368© 2009 IBM Corporation

Model/View/Controller

Creating a controller isn’t so bad is it?

Now lets create controllers for each field on our page. Copy/paste code is provided in the notes. Since there really is no better way to teach this, the code provided is heavily commented. We will rely on these comments and simple intuition to teach the remaining controller concepts not explained.

The code in the notes should simply be pasted below the view widgets.

Page 369: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

369© 2009 IBM Corporation

Model/View/Controller

Note the additional functions we utilize in certain controllers, such as validators

Remember that the code is heavily commented. Utilize those comments and examine the Controller widget itself in order to understand the remaining functionality available.

So, now that we have implemented the entire MVC spectrum, what’s left? Well, as we discussed on previous slides, forms are often used to group models, views, and controllers together.

Page 370: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

370© 2009 IBM Corporation

Model/View/Controller

Grouping all of this data so that a single submit can be issued is the ultimate goal of the framework. Doing so will introduce a couple of new widgets!

Returning to our code, lets create an array of form fields. These are essentially the items we want inside of our form. The syntax consists of a String you would like displayed on the page and which controller it conforms to.

Add the following code to your RUI Handler above the view code

Copy/paste code provided in the notes

Page 371: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

371© 2009 IBM Corporation

Model/View/Controller

Now that we’ve got our form fields, lets create a form!

Add the following lines of code to your RUI Handler

Don’t forget to press Ctrl/Shift/O

Note that this is simply a declaration of a new widget that encompasses the form fields.

By now you should be realizing that this form is actually a UI widget, meaning it generates and displays components and data on the page.

Page 372: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

372© 2009 IBM Corporation

Model/View/Controller

Finally, we have one last step! We need to create a event that will trigger the submission of the form!

Let’s add a button to the page that will do just that Add the following code… Note that we are also adding the button to the initialUI property of the RUIHandler

Finally, go to the next slide to add the submit logic

Page 373: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

373© 2009 IBM Corporation

Model/View/Controller

Copy the code in the notes section of the slide and paste it into the RUIHandler (for readability’s sake, paste it below the existing functions in the RUIHandler) Note that the code is commented sufficiently so that understanding the logic should be

intuitive.

Finally, let’s preview the page…

Page 374: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

374© 2009 IBM Corporation

Course

Units:

RBD/EGL DevelopmentRBD/EGL Development

JavaScript ExternalTypeJavaScript ExternalType

Page 375: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

375© 2009 IBM Corporation

Calling custom JavaScript from Rich UI

So what happens if you’ve already got a bunch of custom JavaScript written within your company?? Does it all go to waste now that you’ve got Rich UI?

The answer to this question is no. Rich UI provides a way to interface with any custom JavaScript that you may currently have.

Lets do a workshop that is twofold! We will write and call some logic written in pure JavaScript, then write and call a widget written in pure JavaScript.

Create the following folder structure inside of the com.ibm.egl.education.widgets project under the WebContent folder. customJavaScript functions customJavaScript widgets

Page 376: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

376© 2009 IBM Corporation

Calling custom JavaScript from Rich UI

Next, under the WebContent customJavaScript functions folder, create a new JS file called customFunctions.js

Once the file is created, copy the code in the notes and paste it into the file.

Note the constructor, which is simply a function that is executed when an object of this class is created.

Also note the hello function. This is our custom function which takes a parameter and returns a string!

Page 377: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

377© 2009 IBM Corporation

Calling custom JavaScript from Rich UI

Next, under the WebContent customJavaScript widgets folder, create a new JS file called customWidgets.js

Once the file is created, copy the code in the notes and paste it into the file.

Notice the “showButton” function, which creates our custom widget using pure JavaScript

Page 378: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

378© 2009 IBM Corporation

Calling custom JavaScript from Rich UI

Now that we have our custom JavaScript written, lets create an ExternalType to interface with this code!

Create a new EGL Package under the same project called customJavaScript.

Next create a new EGL Source File called customExternalTypes

Page 379: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

379© 2009 IBM Corporation

Calling custom JavaScript from Rich UI

Now that we have created the custom JavaScript and the ExternalType to interface to that JavaScript, let’s create a RUI Handler and integrate it all together.

Create a new Rich UI Handler under the customJavaScript package called customExternalTypesDemo

Note that there is copy/paste code in the notes!

Page 380: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

380© 2009 IBM Corporation

Calling custom JavaScript from Rich UI

Preview the page and note the functionality.

Note that the workshop we did was not the traditional hand holding.

We expect that if you are calling custom JavaScript you are well versed in this genre and should be able to move forward by simply being presented with the concepts!

Page 381: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

381© 2009 IBM Corporation

Course

Units:

RBD/EGL DevelopmentRBD/EGL Development

DeploymentDeployment

Page 382: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

382© 2009 IBM Corporation

Deployment

Deploying a Rich UI application consists of generating all of your code into one single HTML file.

Doing so is fairly simple, and is done for you by the tooling.

For deployment you have three options: Deploy as straight HTML artifacts Deploy into a Dynamic Web Project targeted to WAS Deploy into a Dynamic Web Project targeted to Tomcat

In any case, if services calls are made from within the application, we must make sure that the environment contains the Rich UI Proxy.

If deploying into a dynamic web project targeted to either WAS or Tomcat, this is taken care of for you!

If deploying as straight HTML artifacts, a proxy (possibly written in PHP) must be provided manually.

Page 383: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

383© 2009 IBM Corporation

Deployment

First lets switch our generation mode to Deployment Go to Window Preferences EGL Rich UI

Once the change has been made, click apply and OK.

The IDE will prompt you to ask if you want to re-generate all artifacts, simply click OK

Page 384: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

384© 2009 IBM Corporation

Deployment

Now that our code has been generated for deployment, lets deploy!

Right-click over the project and select Deploy EGL Rich UI Application

Page 385: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

385© 2009 IBM Corporation

Deployment

A wizard will pop-up, and for our purposes, we will select the following options.

Click Next

Page 386: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

386© 2009 IBM Corporation

Deployment

On the next screen in the wizard we are given the opportunity to name the output html file, asked where we want the code generated, and given the opportunity to make some globalization settings We can either generate the code to an existing project, or have the wizard create a brand

new Dynamic Web Project

Page 387: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

387© 2009 IBM Corporation

Deployment

Finally click Next and then Finish

Now expand the project where your code was generated and look under the WebContent folder. Notice all of the generated artifacts and

the main html file which contains all of the generated RUI Code

Page 388: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

388© 2009 IBM Corporation

Deployment

For deployment, there exists one final step!

We must export and deploy the Dynamic Web Project. This can be done by exporting a WAR file, or in the case of a WAS project, exporting an

EAR file.

As long as you have generated your code to a Dynamic Web Project, all service calls should work since the proxy is also generated!

Page 389: ® IBM Software Group © 2009 IBM Corporation Rational Business Developer EGL Rich UI Development.

389© 2009 IBM Corporation

Course

Units:

RBD/EGL DevelopmentRBD/EGL Development

What is Web 2.0?

Programming in EGL Rich UI

Learn EGL Rich UI

AppendixAppendix

Under Construction