®
Best Practices for Creating Applications withIBM WebSphere Portlet Factory
Jonathan Booth | Senior Architect, WebSphere Portlet Factory | IBM
AD504
Best practices topics
Introduction Creating applications using a service oriented architecture
Controlling and customizing the user interface Choosing the right builder Building multiple application variations with profiling Optimizing performance Building for multiple platforms Top 10 development best practices Q & A
4
WebSphere Portlet Factory
Rapid development
Robust integration capabilities (SAP, Domino, relational DB, web services and REST services, PeopleSoft, Siebel, and more)
Service-oriented development
Support for many deployment platforms: WebSphere Portal WebSphere Application Server (servlet or portlet) IBM MashupCenter (widget) Lotus Notes 8.x
Runs on Eclipse or IBM Rational tools
IBM WebSphere Portlet Factory simplifies & accelerates the development of custom portlets and applications
5
Key concepts: builders
Capture design patterns and automate the creation of code
Have easy to use, wizard-like interfaces
Create or modify any number of application elements
Pages, schemas and data, server-side and client-side actions and logic, back end connectivity, etc.
/** * Generated Method [employees_SelectRow] */public void employees_SelectRow(WebAppAccess webAppAccess,
Integer rowIndex, String nextAction) { int index = rowIndex.intValue(); Variables vars = webAppAccess.getVariables(); int selectedRow = index - 1; IXml data = vars.getXml("employeesGetEmployeesByDeptResults"); if (data == null) return; data = data.findElement("EmployeeList"); if (data == null) return; int row = 0; IXml child = data.getFirstChildElement(); while (child != null) { if (row == selectedRow) { vars.setXml("employees_SelectedRowData", child); break; } row++; child = child.getNextSiblingElement(); } webAppAccess.callMethod( "employeesGetEmployeeRecord" );
webAppAccess.processAction(nextAction);}
6
Key concepts: models
Models are containers for builders
Developers work iteratively with builders in a model, adding and modifying builders to get desired functionality
A model is typically used to create a service or presentation pages
●Portlet Factory and software automation
Portlet Factory’s model-based development paradigm – using builders – is different than other development tools
You specify the inputs that control code generation Builders generate all the code, optionally incorporating hand-edited code
Builders implement patterns – from high-level service and user interface patterns, to low-level page elements
The benefit of this approach is rapid development and a high degree of automation
Best practices have evolved over the past several years of experience with this paradigm
Best practices topics
Introduction Creating applications using a service oriented architecture
Controlling and customizing the user interface Choosing the right builder Building multiple application variations with profiling Optimizing performance Building for multiple platforms Top 10 development best practices Q & A
●Service oriented builders in Portlet Factory SOA builders in Portlet Factory make it easy to implement a service provider/consumer architecture
These builders work in a consistent way with any back end data source:
Data integration builders provides access to data source Service Definition builder defines a service provider model for use by consumers
Service Operation builders define the operations to expose to consumers Service Consumer allows you to consume service operations in presentation models
10
Presentation models
Service Consumer
Service
Definition
SQL Call
Service
Operation
Service
Operation
SQL Call
Service model
DB Service Consumer
View & Form
View & Form
Service and presentation models
11
Presentation models
Service Consumer
Service
Definition
Domino Data
Access
Service
Operation
Service
Operation
Domino Data
Access
Service model
Service Consumer
View & Form
View & Form
Service and presentation models – Domino
12
Presentation models
Service Consumer
Service
Definition
Web Service Call
Service
Operation
Service
Operation
Web Service Call
Service model
Service Consumer
View & Form
View & Form
Remoteserver
or Enterprise Service Bus
Service and presentation models – web services
Benefits of using a service architecture
Separate back end and presentation development
Automatic support for service testing
Develop consumer (presentation) model without any back end access, using stub service model
Reuse services in multiple presentation models
Transform data between back end schema and some other schema
Switch between service implementations without changing consumer model Demo:
creating a portletusing a service
architecture
High-level steps for application development1. Create a service model for data access
2. Use builder such as View & Form to create the initial presentation Forms and views are automatically generated from the schema
3. Use high-level builders to control overall user interface
4. Apply fine-grained builders where needed For example, for additional navigation
5. Add and modify builders iteratively until the application functions and looks as desired
Best practices topics
Introduction Creating applications using a service oriented architecture
Controlling and customizing the user interface Choosing the right builder Building multiple application variations with profiling Optimizing performance Building for multiple platforms Top 10 development best practices Q & A
●Controlling and customizing the user interface
Portlet Factory uses “Page Automation” technology to generate pages based on schema definitions
For example, View & Form builder and Data Page builder Best practice is to use this automation for any data display and input
These builders work with a whole set of fields at a time They adapt automatically to schema changes
Builders are used to customize and control the various aspects of the user interface:
Forms and data display (formatting, validation, pickers, etc.)
Overall style and look and feel (colors, fonts, etc.) Page layout Navigation and other added elements
Controlling the UI: forms and data display
Portlet Factory has several builders for controlling and customizing forms and views
Some builders target a whole set of page elements, for maximum automation
Rich Data Definition applies UI characteristics (validation, formatting, UI type, labels, etc.) across many fields
Other builders target a specific page element Data Field Modifier sets UI characteristics Attribute Setter sets HTML attributes
Goal: use maximum automation whenever possible; use detailed individual customization when needed
Controlling forms and views with Rich Data Definition
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://bowstreet.com/2002/10/generatedschema1" targetNamespace="http://bowstreet.com/2002/10/generatedschema1">
<xsd:element name="ORDER_ID" type="xsd:string" />
<xsd:element name="DATE_ORDERED" type="xsd:string" />
<xsd:element name="STATUS" type="xsd:string" />
<xsd:element name="DATE_SHIPPED" type="xsd:string" />
<xsd:element name="QUANTITY" type="xsd:string" />
<xsd:element name="AMOUNT" type="xsd:string" />
<xsd:element name="BILLING" type="xsd:string" />
<xsd:element name="SHIPPED" type="xsd:string" />
<xsd:element name="STATE" type="xsd:string" />
</xsd:schema>
Schema
Controlling forms and views with Rich Data Definition
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://bowstreet.com/2002/10/generatedschema1" targetNamespace="http://bowstreet.com/2002/10/generatedschema1">
<xsd:element name="ORDER_ID" type="xsd:string" />
<xsd:element name="DATE_ORDERED" type="xsd:string" />
<xsd:element name="STATUS" type="xsd:string" />
<xsd:element name="DATE_SHIPPED" type="xsd:string" />
<xsd:element name="QUANTITY" type="xsd:string" />
<xsd:element name="AMOUNT" type="xsd:string" />
<xsd:element name="BILLING" type="xsd:string" />
<xsd:element name="SHIPPED" type="xsd:string" />
<xsd:element name="STATE" type="xsd:string" />
</xsd:schema>
Schema
Rich Data Definition for
schema
ORDER_ID
DATE_ORDERED
STATUS
STATE
Rich Data Definition Shared Library
base_Date
base_Currency
base_US_State
Demo: using Rich Data
Definition
Controlling the UI: overall style and look and feel
New in Portlet Factory 6.1.2: Themes
Themes allow you to centrally control and modify the look and feel:
Styles (CSS) Page layouts Table and form layout rules Table highlighting and paging controls
A theme can be applied for a model, or automatically for a whole project
You can also override specific theme elements at any level
Demo: using themes
●Controlling the UI: page layouts
Overall page layout is controlled with imported HTML pages
Imported pages include placeholders (named tags) where content will be inserted
Field layout, grouping, and visibility can be controlled with builders
For complete customization of field layout, use an HTML page with all the field locations (named tags) for a schema
Use “Export HTML” command to create HTML file with named tags Select the generated file in builder such as View & Form Iteratively modify the HTML file using an HTML editor to position fields as desired
Controlling the UI: navigation and other added elementsThere is a large set of builders that add elements to pages:
Navigation (buttons, links, tabs, etc.)
Inserted pages and models
Ajax functionality Builders generate all the needed client-side and server-side code
Dojo features Drag and drop Popup “tooltip” windows Rich Text Editor
Demo: using Dojo
and Ajax
Best practices topics
Introduction Creating applications using a service oriented architecture
Controlling and customizing the user interface Choosing the right builder Building multiple application variations with profiling Optimizing performance Building for multiple platforms Top 10 development best practices Q & A
●Choosing the right builder Portlet Factory has over 150 builders, and it's not always easy to know the best builder for a task
This next section lists some common tasks, showing the builder that is best used to accomplish the task
It is derived from the “Getting Started Guide” located at: http://www-10.lotus.com/ldd/pfwiki.nsf/dx/getting-started-with-portlet-factory-6.1
You aren't expected to remember everything from these slides! Get a sense of what's available Refer to the Getting Started Guide when you do your work
Choosing builders – creating services
Task Builder
Get access to data store •Use data access builder from following slide
Define a service •Service Definition
Add an operation to a service •Service Operation
Generate a test harness for a service
•Use the “testing support” inputs of Service Definition builder
Create a stub service model •In Service Definition builder, use the “Generate Stub” button
Create a WSDL/SOAP service provider
•In Service Definition builder, use the “Generate WSDL” checkbox
Create a REST service provider
•REST Service Enable
Choosing builders – data access builders
System or Data Source Builder
Relational database SQL Call
Lotus® Domino® Domino Data Access
Microsoft® Excel® Excel Import
Java™ class Linked Java Object
PeopleSoft® Peoplesoft Component Interface
SAP® SAP Function Call
Siebel® Siebel Business Component
Web Service Web Service CallWeb Service Multiple Operations
REST service, including Lotus Connections and Lotus Quickr
REST Service Call
XML Data Variable or Import to XML
Human tasks from WebSphere Process Server
Builders from Business Process Integration Extension (SOA Catalog)
Demo: accessing Lotus
Connections usingREST
services
Choosing builders – creating the initial user interface
Task Builder
Access a service model •Service Consumer
Create portlet pages based on service data •View & Form•Input Form
Create a page with a graphical chart of data •Imported Page and Web Charts
Make a model available as a portlet •Portlet Adapter
Add some structured data to a page, for viewing, input, or update
•Data Page
Choosing builders – working with columns and data layout
Task Builder
Hide columns in a table •Data Column Modifier•Rich Data Definition
Add sorting capabilities •Data Column Modifier
Reorder the columns in a table or add new columns
•Data Column Modifier
Add grouping to fields on a page •Data Hierarchy Modifier
Create multiple columns for form data •Form Layout
Add buttons to expand and collapse data by category
•Category View
Display and hide detail information •Collapsible Section
Choosing builders – validation, formatting, and field UI
Task Builder
Format and validate data in fields
•Rich Data Definition – for maximum automation•Data Field Modifier – for individual fields
Change the UI behavior for a field (e.g., change to checkbox or radio button, mark read-only, or create a link)
•Rich Data Definition•Data Field Modifier
Create user-friendly labels for fields
•Data Column Modifier•Rich Data Definition•Create resource bundle using “Export Resource Bundle”
from page, then reference from builders such as View &
Form
Translate internal values into meaningful names
•Lookup Table•Rich Data Definition (create Lookup from RDD XML file)•Apply a lookup table to pages with Data Field Modifier,
Select, Text, or Radio Button Group
Choosing builders – actions and events
Task Builder
Create a list of actions •Action List
Assign a value to a variable •Action List (select Assignment under “special” actions)
Use some Java code •Linked Java Object•Method
Add portlet-to-portlet communication •Cooperative Portlet Source and Cooperative Porlet Target (for Property Broker Events or Wired Portlets) •Event Declaration and Event Handler (for simple events)
Add error handling to a portlet •Error Handler
Add caching to improve performance
•Cache Control•Service Operation builder – caching option
Choosing builders – navigation and page actionsTask Builder
Add action controls to a page •Button•Image Button•Link
Run an action when a form is submitted
•Form Submit Action
Run an action when a user clicks or types on a page
•HTML Event Action
Put pages onto separate tabs with navigation between tabs
•Page Tabs
Add paging controls to a table •Use the paging options in View & Form builder•Data Column Modifier with Paging Buttons or Paging
Links
Link to another portlet on same or different page
•Cooperative Portlet Source/Target
Add a drop-down menu to a page •Contextual Menu
Choosing builders – controlling page elements
Task Builder
Show/hide an element based on a condition
•Visibility Setter
Set an HTML attribute for a specified page element
•HTML Attribute
Localize the text strings for a portlet
•Localized Resource
Insert one page in another •Inserted Page
Display some read-only text on a page
•Text
Add some client-side JavaScript to a page
•Client JavaScript™
Demo: creating a multi-language portlet
Choosing builders – using schemas and variables
Task Builder
Create an XML variable •Variable
Use an existing schema •Use Schema builder to reference existing XSD file•Use Variable builder to create a variable based on the
schema
Create a simple schema •Use Variable builder to create an XML variable with the desired structure•Use Simple Schema Generator to make a schema from
Variable
Use an existing Java Bean •Linked Java Object•Java/XML Converter can be used to convert to XML
Transform data between schemas
•Use Service Operation builder for simple mapping•Transform builders•For more complex XML manipulation, use Java code that
manipulates Ixml•Transform builders
Choosing builders – portal integration featuresTask Builder
Make a model available as a portlet •Portlet Adapter
Wire your portlets together and communicate between them
•Cooperative Portlet Source and Cooperative Porlet Target
Add support for Edit and Configure mode
•Use Edit and Configure settings in Portlet Adapter builder, after profiling builder inputs
Create a customizer for a business user or administrator
•Use Portlet Customizer in a customizer model•Specify your customizer as a “custom model”
choice in the Portlet Adapter builder of your portlet
Integrate ‘people awareness’ or Sametime chat capabilities
•People Awareness (part of Lotus Collaboration Extension feature set)
Retrieve user credentials from Credential Vault, to support single sign-on with external back end applications
•WebSphere Portal Credential
Choosing builders – using Ajax and Dojo
Task Builder
Use partial page refresh for a region of a page or for an entire model
•Ajax Region Builder
Use partial page refresh for a specific action
•Use page action builders such as Link or Button•Set the “Post Action Behavior” to “Refresh specified page location after running action”
Use client side events •Event Declaration Builder•Client Event Handler Builder
Enable Drag and Drop on your page
•Dojo Drag Source •Dojo Drop Target
Add popup “hover” information to a page element
•Dojo Tooltip
Other Ajax related builders to explore
•Ajax Type-Ahead, Dynamic Validation, Dojo Enable, Dojo Inline Edit, Timed Action, Highlighter, Global Ajax Enablement, XML/JavaScript Converter
Choosing builders – sharing model functionality
Task Builder
Use some common builders in a number of models
•Imported Model
Include another model visually on a page, with support for navigation in the contained model
•Model Container
Reuse the actions or methods of another Model
•Linked Model
Best practices topics
Introduction Creating applications using a service oriented architecture
Controlling and customizing the user interface Choosing the right builder Building multiple application variations with profiling Optimizing performance Building for multiple platforms Top 10 development best practices Q & A
●Building multiple application variations with profiling
Dynamic profiling can be used to generate multiple application variations from a single source model
Variations can be tied to user roles, groups, or other attributes
For different customers, partners, regions, etc.
Profiling also supports customization by administrators or end users
Configure, Personalize, and Edit Shared Settings in Portal Enables business users to customize the application – without requiring additional coding by developers
Any aspect of application can be varied by profile: look and feel, level of functionality, services, logic, etc.
Demo: dynamic profilin
g
Best practices topics
Introduction Creating applications using a service oriented architecture
Controlling and customizing the user interface Choosing the right builder Building multiple application variations with profiling Optimizing performance Building for multiple platforms Top 10 development best practices Q & A
●Best practices for performance and scalability
Avoid retrieving large data sets● Try to retrieve small or moderate size data sets● Use paging to back end if possible
1 Enable cross-user caching when feasible● Enabled with Service Operation or Cache Control builders
2 Use Portlet Factory's built-in performance logging and tracing tools
● See next slide
3 Avoid deploying a large number of Portlet Factory WAR files
● A single WAR can include any number of portlets
4 Use automated load test tools to validate performance
5 Use the latest version of Portlet Factory
6 See recommendations from the tuning guide for WebSphere Portal
Built-in performance logging and tracing tools
System tracing or model action tracing The quickest way to pinpoint any slowness for particular actions
Instantly shows where the time is spent Easily enabled when running from Designer or with property file
Server stats A log file that periodically captures statistics about usage and performance on a running server under load
See the WEB-INF/logs/serverStats.txt file in deployed WAR Captures numerous statistics, such as request actions and their latency and requests to external systems
Session size diagnostics Reports estimated size of session variables
Demo: using system tracing
Best practices topics
Introduction Creating applications using a service oriented architecture
Controlling and customizing the user interface Choosing the right builder Building multiple application variations with profiling Optimizing performance Building for multiple platforms Top 10 development practices Q & A
43
●Building for multiple platforms Portlet Factory can be used to build applications for:
WebSphere Portal Server 6.0, 6.1
WebSphere Application Server 6.0, 6.1, 7.0 (as servlet or portlet)
Lotus Mashups 1.0, 1.1 (as widget) - New in Portlet Factory 6.1.2
Lotus Notes 8.x or Expeditor 6.1.1+ (as portlet)
44
WebSphere Portal
A Factory for all platforms
Use one common set of tools, techniques, and
application code…
Process Servertasks
Quickr and Connectionsservices
Databases
Domino
MashupHub Feeds
Web services andREST services
SAP
…and deploy to many platforms
Portlet Factory
WebSphereApplication Server
Notes 8 / Expeditor
Lotus MashupsPeopleSoft
Siebel Demo: running
onLotus Mashups
45
Considerations for multiple platforms The vast majority of builders work on all platforms
Data integration, services, page automation, theme, etc.
A few builders need special consideration Eventing: no Cooperative Portlet on Mashups or WebSphere Application Server (use widget events or basic Portlet Factory events instead)
Portal-specific builders or APIs such as Credential Vault, Portal Group profile selection, and People Awareness cannot be used on non-Portal platforms
Profiling can be used to dynamically enable/disable platform specific builders
E.g., “Portal Execution Mode” profile selection handler
Best practices topics
Introduction Creating applications using a service oriented architecture
Controlling and customizing the user interface Choosing the right builder Building multiple application variations with profiling Optimizing performance Building for multiple platforms Top 10 development best practices Q & A
Top 10 development best practices
1 Use a service provider/consumer model architecture
2 Use the highest-level builder available for the job
3 Use Page Automation builders for display and input of data (View & Form, Input Form, Data Page)
4 Use Rich Data Definition to simplify and centralize field formatting, validation, and UI
5 Try to keep model size under 50 builders
Top 10 development best practices
6 Don't write lots of code in Method builder - use Linked Java Object instead
7 Use the Theme support in Portlet Factory 6.1.2 to control UI style
8 Use system tracing feature to examine program flow and to look for performance issues
9 Use the samples on the wiki to get going quickly with new techniques
10 Utililize the developerWorks forums for specific questions or problems
Additional information and resources
Portlet Factory wiki http://www-10.lotus.com/ldd/pfwiki.nsf Includes numerous samples and articles, best practices documents, and links to other resources
Portlet Factory forums on developerWorks http://www-01.ibm.com/support/docview.wss?rs=3044&uid=swg27011853
These are very active and are monitored closely by the Portlet Factory team
Portlet Factory zone on developerWorks http://www.ibm.com/developerworks/websphere/zones/portal/portletfactory/
®
Q & A
Legal disclaimer © IBM Corporation 2008. All Rights Reserved.
The information contained in this publication is provided for informational purposes only. While efforts were made to verify the completeness and accuracy of the information contained in this publication, it is provided AS IS without warranty of any kind, express or implied. In addition, this information is based on IBM’s current product plans and strategy, which are subject to change by IBM without notice. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this publication or any other materials. Nothing contained in this publication 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 this presentation to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. Product release dates and/or capabilities referenced in this presentation 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. Nothing contained in these materials is intended to, nor shall have the effect of, stating or implying that any activities undertaken by you will result in any specific sales, revenue growth or other results.
IBM, the IBM logo, Lotus, Lotus Notes, Notes, Domino, Quickr, Sametime, WebSphere, UC2, PartnerWorld and Lotusphere are trademarks of International Business Machines Corporation in the United States, other countries, or both. Unyte is a trademark of WebDialogs, Inc., in the United States, other countries, or both.
IJava and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.
I
®
Extra slides