EGL-RichUI-Sales-Training.ppt
-
Upload
sampetruda -
Category
Documents
-
view
2.724 -
download
0
Transcript of EGL-RichUI-Sales-Training.ppt
®
IBM Software Group
© 2006 IBM Corporation
Rational Business Developer
EGL Rich UI Development
2© 2008 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.
3© 2008 IBM Corporation
Contributing Authors
Scott Pecnik and Jon Sayles – primary content and courseware developers
Ancillary contributors: William Smythe,Yann Lerouzic/Morpheus Consulting, U.K.,
4© 2008 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 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 s and have a
comfortable understanding of EGL and JSF technology – especially, with the AJAX portion of the EGL-JSF course
Alternatively, if you have the equivalent EGL work experience doing production dynamic content web application development using Eclipse, EGL and JSF that should be sufficient
An understanding of basic HTML is also assumed HTML tables HTML components such as input fields, radio buttons, etc.
5© 2008 IBM Corporation
Course Introduction – Unit Descriptions
The What is Rich UI? unit explains what the EGL Rich User Interface technology is and what you can accomplish with it.
The Terms and Concepts unit will further drill down into Rich UI and the technologies it uses.
The Programming in EGL Rich UI unit will give you an introduction to coding web pages in EGL Rich UI.
6© 2008 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
7© 2008 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
8© 2008 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
9© 2008 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)
10© 2008 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
11© 2008 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”
12© 2008 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
13© 2008 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.
14© 2008 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
15© 2008 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 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
16© 2008 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/
17© 2008 IBM Corporation
Web 2.0/RIA – 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
18© 2008 IBM Corporation
Course
Units:
RBD/EGL DevelopmentRBD/EGL Development
What is Rich UI ?What is Rich UI ?
Programming in EGL Rich UI
Learn EGL Rich UI
Appendix
19© 2008 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)
20© 2008 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
21© 2008 IBM Corporation
EGL: Shielding Complexity – Across the Development Lifecycle
Consume Data + Logic
UI Produce
JavaScriptAJAXDojoGoogle
REST XMLSOAP JSON
SOAPXMLRESTPHP
COBOLJava RPGSQL
EGL Widget Library
IBM
Widget Writer
ISVs
Business Developers
Business Developers
EGL
22© 2008 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
23© 2008 IBM Corporation
Rich UI 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
24© 2008 IBM Corporation
Technical Terms and Concepts
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
25© 2008 IBM Corporation
Terms and Concepts - continued
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:
26© 2008 IBM Corporation
EGL Rich UI – Modular Development and 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: Rich UI application design tends towards reuse – as all interfaces are formally declared The EGL language 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
27© 2008 IBM Corporation
What Developers are Saying About 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.
28© 2008 IBM Corporation
Course
Units:
Learn EGL Rich UILearn EGL Rich UI
Create a new projectCreate a new 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
29© 2008 IBM Corporation
Create a new project*** Scott to provide new screen-caps Let’s start the tutorials by creating our very own Rich UI project!
Select File New Project
In the new project wizard, select EGL Project, and then click Next
30© 2008 IBM Corporation
Create a new project The wizard should then ask you to provide a name for your project
Type EGLRich UI Next make sure to select Rich UI Project as your project type
Next, click Finish The IDE will take a minute or two to create your project and set up the environment Then we’ll be set up for the rest of the course
31© 2008 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: RUIWidget definitions (more on these
later) Core language functionality
EGL Data Types Service Call API’s Publish/Subscribe Framework MVC Framework Event handling logic Etc.
32© 2008 IBM Corporation
Developing in Rich UI Let’s learn about what it’s like to develop using EGL Rich UI
The quintessential view is the EGL Rich UI Editor
This view contains a design, source, and preview mode
These three views 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 look like!
These three views are where you will spend a large majority of your time as a Rich UI developer
33© 2008 IBM Corporation
Course
Units:
Learn EGL Rich UI*** Jon Learn EGL Rich UI*** Jon to consolidate – renameto consolidate – rename
The Rich UI Environment
Create a new project
Hello World
EGL Rich UI “Basics”EGL Rich UI “Basics”
Web Application Layout and Design
Event Driven Development
Input Controls
Data Tables
Login Page
Calling a Service
34© 2008 IBM Corporation
Rich UI Perspective Similar to Web Perspective – but with different Views
Content AreaContent Area
PalettePalette
Project ExplorerProject Explorer
Outline,Properties and Events
Views
Outline,Properties and Events
Views
Problems&
Generation ResultsViews
Problems&
Generation ResultsViews
35© 2008 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: RUIHandler per se’ RUIHandler of sub-type RUIWidget
36© 2008 IBM Corporation
RUIHandlers
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…
Rich UIRich UIElementsElements
EGL Function(s)EGL Function(s)……
37© 2008 IBM Corporation
RUIHandlers – Example Using IBM-provided Widgets and Their Code
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
38© 2008 IBM Corporation
RUIHandler – With 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)
39© 2008 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
40© 2008 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
41© 2008 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>
42© 2008 IBM Corporation
RUIWidget Properties – EGL Coding Example
To specify a RUIWidget property 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
43© 2008 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:includeFile = “relative/fileSpec.fileName.css”includeFile = “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)
44© 2008 IBM Corporation
“What about those events?” – Basics of Rich UI Coding – Event Handling
EGL Rich UI utilizes what is called event 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 tied to it.
You can specify these 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 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
45© 2008 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] };
46© 2008 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!
47© 2008 IBM Corporation
Basics of Rich UI Programming – ExternalTypes – access to JavaScript
Reuse existing native JavaScript functionality
48© 2008 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 Design and Box Workshops Additional Workshop
– Calculator– Temperature Converter– Login
49© 2008 IBM Corporation
Workshop – Exploring Using Rich UI 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
50© 2008 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
51© 2008 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
52© 2008 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)
53© 2008 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
54© 2008 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
55© 2008 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
56© 2008 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
57© 2008 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
58© 2008 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.
59© 2008 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.
60© 2008 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.
61© 2008 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.
62© 2008 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
63© 2008 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
64© 2008 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
65© 2008 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!
66© 2008 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
67© 2008 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!
68© 2008 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
69© 2008 IBM Corporation
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.
70© 2008 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
71© 2008 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.
72© 2008 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
73© 2008 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
74© 2008 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
75© 2008 IBM Corporation
Calculator 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…
76© 2008 IBM Corporation
Calculator – Optional Functionality 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
77© 2008 IBM Corporation
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
78© 2008 IBM Corporation
OPTIONAL – 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
79© 2008 IBM Corporation
OPTIONAL – 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 formulae
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
80© 2008 IBM Corporation
Workshop – an Online Login 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:
Styling elements – to enhance the U.I. Event handlers – to provide for immediate feedback to the user
81© 2008 IBM Corporation
Workshop – an Online 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
82© 2008 IBM Corporation
Workshop – an Online 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
83© 2008 IBM Corporation
OPTIONAL 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