Download as pdf or txt
Download as pdf or txt
You are on page 1of 48

International Technical Support Organization

Introduction to JavaServer Faces (JSF) Development

IBM eServer iSeries


ibm.com
the power of one ITSO Technical Forum 2005

Elena Lowery, IBM Corporation

International Technical Support Organization

IBM Confidential until announced © 2005 IBM Corporation


ibm.com/redbooks International Technical Support Organization

Agenda
▪ Brief History of Dynamic Web Application Development
▪ JavaServer Faces Overview
▪ JavaServer Faces Development Tools
▪ Integration with iSeries applications and data
▪ Getting Started with JSF Development

IBM Confidential until announced. © 2005 IBM Corporation 2


ibm.com/redbooks International Technical Support Organization

History of Dynamic Web Application Development


▪ Perl / CGI (Common Gateway Interface)
▪ Servlet API
▪ JavaServer Pages
▪ Web Development Frameworks

IBM Confidential until announced. © 2005 IBM Corporation 3


ibm.com/redbooks International Technical Support Organization

Perl / CGI
▪ HTTP Request/Response model
▪ CGI bin runs in HTTP Server
▪ Drawbacks
– Performance compared to other Web technologies
– Scalability
– Difficult to maintain
– No built-in session management

Browser HTTP Server

HTML Form
CGI Script Database
CGI Script
HTML Page

IBM Confidential until announced. © 2005 IBM Corporation 4


ibm.com/redbooks International Technical Support Organization

Perl / CGI Sample code

HTML is embedded
in CGI Script

IBM Confidential until announced. © 2005 IBM Corporation 5


ibm.com/redbooks International Technical Support Organization

Servlet API
▪ Simplified Web application development compared to Perl/CGI
model:
– Session Object
– Request/Response Objects
▪ Improved performance and scalability
– Once Servlet is Loaded it Remains in Memory
– Multiple Concurrent Requests Handled by Separate Threads
▪ Added functionality:
– Full Arsenal of Java APIs
• Runs in middleware (for example, WebSphere Application
Server) and that further improves manageability, performance
and scalability
• Tools (for example, WebSphere Studio) simplify development

IBM Confidential until announced. © 2005 IBM Corporation 6


ibm.com/redbooks International Technical Support Organization

Servlet API
▪ Drawbacks
– Maintenance problems similar to Perl/CGI: HTML is embedded in servlet
code

IBM Confidential until announced. © 2005 IBM Corporation 7


ibm.com/redbooks International Technical Support Organization

Servlet API
▪ Drawbacks
– JavaScript: complexity, portability between browsers and maintenance

IBM Confidential until announced. © 2005 IBM Corporation 8


ibm.com/redbooks International Technical Support Organization

JavaServer Pages
▪ Better architecture
– Model-View-Controller (MVC) pattern: separation of presentation and business
logic
– Code reuse
– Easier to maintain

View Controller Model

JavaBean
JSP

JSP Servlet
EJB

JSP
Web Service

IBM Confidential until announced. © 2005 IBM Corporation 9


ibm.com/redbooks International Technical Support Organization

JavaServer Pages
▪ JSP Phase 1
– Instead of HTML inside Java – Java Inside HTML
– JSPs compiled into servlets

▪ JSP Phase 2
– Java Standard Tag Library (JSTL)
– Custom Tag Libraries

IBM Confidential until announced. © 2005 IBM Corporation 10


ibm.com/redbooks International Technical Support Organization

JSP and Struts


▪ Struts is Open Source implementation of the MVC design pattern
▪ Struts is implemented as a set of Java classes and JSP tag libraries
▪ Struts helps manage Web application development and maintenance and
speeds up development cycle

IBM Confidential until announced. © 2005 IBM Corporation 11


ibm.com/redbooks International Technical Support Organization

Web Application Development


JSP/servlet programming model is a proven and mature Web application development
technology. Why do we need another technology for developing Web applications?

▪ Up to date, Java Web technologies have been known for:


– Portability
– Scalability
– Flexibility
– Used for building large enterprise solutions

▪ But not
– Rapid Application Development (RAD)
– Short learning curve
– Used for building SMB solutions

IBM Confidential until announced. © 2005 IBM Corporation 12


ibm.com/redbooks International Technical Support Organization

JSF Overview

IBM Confidential until announced. © 2005 IBM Corporation 13


ibm.com/redbooks International Technical Support Organization

JavaServer Faces – Overview


▪ JavaServer Faces (JSF) Technology is a framework for
building Web applications
▪ JSF is an evolutional step in Web application frameworks
development, it builds on Servlet API and JSPs
technologies
▪ JSF is a framework, it does not provide tools for
development – it’s up to the tool vendor to provide JSF
development environment
▪ JSF is an open standard: JSR127

IBM Confidential until announced. © 2005 IBM Corporation 14


ibm.com/redbooks International Technical Support Organization

JavaServer Faces - Overview


▪ JSF Goals
–Make J2EE Web application development RAD
• Drag and drop components
• Event driven model
• Eliminate a great deal of hand coding
–Make it easy to integrate with data sources
–Make is easy for non-J2EE programmers

IBM Confidential until announced. © 2005 IBM Corporation 15


ibm.com/redbooks International Technical Support Organization

JavaServer Faces - Overview


▪ From the technology perspective JSF is a framework for
building Web applications
– Extends Servlet/JSF development model
– Simplifies Web application development
▪ IBM tools provide code generator functionality for JSF
development

IBM Confidential until announced. © 2005 IBM Corporation 16


ibm.com/redbooks International Technical Support Organization

Developing JSF Applications

IBM Confidential until announced. © 2005 IBM Corporation 17


ibm.com/redbooks International Technical Support Organization

JSF Development Tools


▪ IBM JSF Development Tools
– Rational Development V6 Tools
• Rational Application Developer
• Rational Web Developer
• Rational Software Architect
– WebSphere Development Studio Client for iSeries V6 or
V5.1.2

IBM Confidential until announced. © 2005 IBM Corporation 18


ibm.com/redbooks International Technical Support Organization

Developing JSF Applications


▪ Designing JSF applications
– Follow Model-View-Controller (MVC) design pattern
• Model (business logic): JavaBeans, EJBs or Web Services
• View (user interface): JSPs with JSF components
• Controller: no programming required, JSF framework implements the controller

– Access iSeries programs, functions and data in the “Model” part of the application

View Controller Model

JavaBean
RPG

Servlet
EJB
Database

IBM Confidential until announced. © 2005 IBM Corporation 19


ibm.com/redbooks International Technical Support Organization

Accessing iSeries Applications and Data from JSF


▪ RPG/COBOL application requirements
– ILE RPG or COBOL applications that have been written in an “API” format
• Input and output parameters
• Stateless
• No presentation logic

– Use IBM Toolbox for Java API to access iSeries applications and data

View Controller Model


JavaBean
RPG
Servlet Toolbox
for Java iSeries
commands

EJB
Database

IBM Confidential until announced. © 2005 IBM Corporation 20


ibm.com/redbooks International Technical Support Organization

IBM Toolbox for Java


▪ IBM Toolbox for Java: a setup of Java APIs for accessing
iSeries applications, functions, and data
▪ Most frequently used Toolbox APIs for Java and iSeries integration
– Database access via JDBC
– Command Call: invoke any non-interactive iSeries command
– Program Call: invoke an iSeries program
– Data Queues: asynchronous (messaging) communication between Java and
iSeries programs

▪ More information:
• http://www-1.ibm.com/servers/eserver/iseries/toolbox/

IBM Confidential until announced. © 2005 IBM Corporation 21


ibm.com/redbooks International Technical Support Organization

JSF Development
▪ Once business logic is developed, we can start developing JSFs
▪ Development steps:
1. Create a JSF
2. Add JSF components
3. Configure JSF components (properties, validation, binding)
4. Configure Web application navigation

IBM Confidential until announced. © 2005 IBM Corporation 22


ibm.com/redbooks International Technical Support Organization

JSF Development: Tools


▪ Use the Palette View to add JSF
components
– Input boxes, output fields, buttons, combo
boxes, radio buttons, etc.

▪ Most of these components exist in HTML, so


what’s different about them?
– JSF components have properties, respond to
events, have pre-defined behavior and can be
bound to business logic

IBM Confidential until announced. © 2005 IBM Corporation 23


ibm.com/redbooks International Technical Support Organization

JSF Development: Properties


▪ JSF Component properties
– Things that describe a component: id, format, value, and others
– JSF provides automatic validation based on the selected format and other properties
(for example, required)
– Also called Attributes
▪ How do JSF component Properties simplify Web application development?
– Developers don’t have to write code for formatting and validation, which in regular
application development is done in JavaScript

IBM Confidential until announced. © 2005 IBM Corporation 24


ibm.com/redbooks International Technical Support Organization

JSF Development: Binding


▪ Binding
– Attach a value of a JSF component (usually an input field or an output field) with
a request
– Purpose: capture input values for processing and display output values that are
the result business logic execution
– Specified in the Value property the Properties View

IBM Confidential until announced. © 2005 IBM Corporation 25


ibm.com/redbooks International Technical Support Organization

JSF Development: Binding


▪ How does Binding simplify Web application development?
– In regular Web application development we have to write code to capture input
field and display results of business logic execution
– In our experience - 10 to 20 lines of code per field in regular Web application
programming
– In JSF, this is done through configuration

IBM Confidential until announced. © 2005 IBM Corporation 26


ibm.com/redbooks International Technical Support Organization

JSF Development: Events


▪ Events are common in desktop applications programming, but not in Web
applications
▪ Traditional Web applications implement the Request/Response model
▪ JSF applications are Web application, but in addition to the JDBC
JDBC
Request/Response model, they implement the event model JDO
JDO
▪ In JSF, an event is tied to a component DOM
DOM
SAX
▪ Types of JSF component events SAX
JAXB
JAXB
JAX-RPC
– Action event (example: click a button or a hyperlink) JAX-RPC
– Value changed event (example: select a value in a drop down)
SOAP
SOAP

JCA
JCA

IBM Confidential until announced. © 2005 IBM Corporation 27


ibm.com/redbooks International Technical Support Organization

JSF Development: Events


▪ How does the JSF Event model simplify Web application development?
– More intuitive development environment: some code needs to be executed
when a button is clicked. In a regular Web application this code had to be
written manually by submitting a Request
– Configured through Properties and Quick Edit views in RAD
– Example of an action that’s configured (vs. coded): Navigation from page to
page
– In regular application development this task is implemented by an
experienced Java/Web programmer

IBM Confidential until announced. © 2005 IBM Corporation 28


ibm.com/redbooks International Technical Support Organization

JSF Development: Events


▪ How does the JSF Event model simplify Web application development?
– Allows to focus on writing business logic, not figuring out how to wire the
components together
– Select a component, and write business logic for event associated with it
– In regular Web application programming this is a manual step requiring
JavaScript and request handling

IBM Confidential until announced. © 2005 IBM Corporation 29


ibm.com/redbooks International Technical Support Organization

JSF Development: Comparing to JSP/Servlet Development

▪ Simple Web application: perform a search based on values provided


by a user and display results in a table format

▪ JSP/Servlet development:
– 2-3 hours development time
– Approximately 200 lines of code
▪ JSF development
– 30 min
– No code, just drag/drop and configuration

▪ Demo: guess which application is written with JSF

IBM Confidential until announced. © 2005 IBM Corporation 30


ibm.com/redbooks International Technical Support Organization

JSF Development: Development Steps


▪ Typical JSF Development Steps
1. Implement business logic in JavaBeans, EJBs or Web Services
2. Create JSF JSPs: mostly drag and drop
3. Configure field properties
4. Map JSF fields and actions to business logic

▪ Typical JSP/Servlet Web Application Development Steps


1. Implement business logic in JavaBeans, EJBs or Web Services
2. Create JSPs: mostly manual coding
3. Create Servlets
4. Write code to process JSP requests
5. Write code to validate field data

IBM Confidential until announced. © 2005 IBM Corporation 31


ibm.com/redbooks International Technical Support Organization

JSF Development Demo

IBM Confidential until announced. © 2005 IBM Corporation 32


ibm.com/redbooks International Technical Support Organization

JSF Development: What happens behind the scenes

▪ RAD tool generates code based on properties and configuration


parameters specified by the developer
▪ JSF application is a Web application based on Servlet/JSP model, it is
helpful to understand JSP and Servlet programming concepts, but it’s
not required
▪ The generated source code can be modified
▪ Each JSF becomes a Java class
▪ Configuration information is stored in an XML file: faces-config.xml

IBM Confidential until announced. © 2005 IBM Corporation 33


ibm.com/redbooks International Technical Support Organization

Service Data Objects (SDO)

IBM Confidential until announced. © 2005 IBM Corporation 34


ibm.com/redbooks International Technical Support Organization

JSF Development: Service Data Objects (SDO)


▪ Service Data Objects (SDO): data programming architecture and API that
unifies programming across data source types and simplifies data query,
update and introspection from Java applications
▪ Formerly knows as Web Data Objects (WDO)
▪ IBM Rational Application Developer and WebSphere Studio Tools provide
support for SDO

IBM Confidential until announced. © 2005 IBM Corporation 35


ibm.com/redbooks International Technical Support Organization

JSF Development: Service Data Objects (SDO)


▪ SDO components in Rational Tools and WDSC:
– Relational Record component: display, create,
update single records from a JSF
– Relational Record List component: display multiple
records in a JSF
– Other ERP components (SAP, Siebel)
▪ How it works:
1. Drag and drop components from the Palette View to
a JSF
2. Configure connection properties
3. Select fields to display
4. Add conditions

IBM Confidential until announced. © 2005 IBM Corporation 36


ibm.com/redbooks International Technical Support Organization

JSF and iSeries Integration


▪ iSeries Data Integration
– Use SDOs
– Integration with iSeries is the same as integration with
other data sources
– Use Toolbox JDBC driver for database connection during
development
– Use Native JDBC driver if WebSphere Application Server
(JSF runtime environment) and database are on the same
server

IBM Confidential until announced. © 2005 IBM Corporation 37


ibm.com/redbooks International Technical Support Organization

JSF Development: Service Data Objects (SDO)


▪ Relational Record List Sample Configuration

JSP Output

IBM Confidential until announced. © 2005 IBM Corporation 38


ibm.com/redbooks International Technical Support Organization

JSF Development: Service Data Objects (SDO)


▪ How does SDO technology simplify Web application
development?
– Create applications that display, insert and update records without
writing Java code
– In regular Web application development this is a intermediate to
advanced programming task that requires knowledge of JSPs,
JDBC and SQL

IBM Confidential until announced. © 2005 IBM Corporation 39


ibm.com/redbooks International Technical Support Organization

Demo: Relational Record List

IBM Confidential until announced. © 2005 IBM Corporation 40


ibm.com/redbooks International Technical Support Organization

Why Use JSF for Web Application Development


▪ Why choose JSF:
– Simplified Web Application Development
– Less development time
– Increased productivity
– Shorter learning curve

▪ Things to consider when developing JSF applications


– JSF is an evolving standard
– Dependency on JSF Tools
– Less flexibility with generated code

IBM Confidential until announced. © 2005 IBM Corporation 41


ibm.com/redbooks International Technical Support Organization

Deploying JSF and SDO Applications

IBM Confidential until announced. © 2005 IBM Corporation 42


ibm.com/redbooks International Technical Support Organization

JSF and SDO Application Deployment


▪ JSF and SDO applications are fully supported in
WebSphere Application Server V6
▪ JSF and SDO applications are supported in WebSphere
Application Server V5.1 as a Technology Preview
▪ Applications are deployed as regular EAR files, no
additional configuration is required

IBM Confidential until announced. © 2005 IBM Corporation 43


ibm.com/redbooks International Technical Support Organization

Getting Started with JSF Development

IBM Confidential until announced. © 2005 IBM Corporation 44


ibm.com/redbooks International Technical Support Organization

Getting Started with JSF Development


▪ Find the right skills:
– Java programmers: beginner and intermediate
– Web application architects
– RPG programmers (if integrating with iSeries applications)

Skill Skill Level Required/Optional


Web Application Development 2 Required
Java 3 Required
JSP/Servlet API Optional
Rational or WebSphere Studio 3 Required
Modular RPG Application 4 Required
Development
DB2 for iSeries Optional

1 – Beginner, 5 - Advanced

IBM Confidential until announced. © 2005 IBM Corporation 45


ibm.com/redbooks International Technical Support Organization

Getting Started with Toolbox Development: Education


▪ Java programmers
– JSF Redbook: WebSphere Studio 5.1.2 JavaServer Faces and
Service Data Objects (SG24-6361-00)
– IBM developerWorks Web site: www.ibm.com/developerworks
– Learn how to use WDSC and Rational wizards for JSF development
– Review IBM Java Toolbox Programmer’s Guide
– Learn how to use WDSC wizards for Java Toolbox classes
development

▪ RPG programmers
– Learn how to write modular stateless code
– Learn how to use WDSC for RPG development

IBM Confidential until announced. © 2005 IBM Corporation 46


ibm.com/redbooks International Technical Support Organization

Questions and Answers

IBM Confidential until announced. © 2005 IBM Corporation 47


ibm.com/redbooks International Technical Support Organization

Trademarks and Disclaimers


IBM Corporation 1994-2005. All rights reserved.
References in this document to IBM products or services do not imply that IBM intends to make them available in every country.

The following terms are trademarks or registered trademarks of International Business Machines Corporation in the United States, other countries, or both:
AS/400 IBM
AS/400e IBM (logo)
eServer iSeries
OS/400

Lotus and SmartSuite are trademarks of Lotus Development Corporation and/or IBM Corporation in the United States, other countries, or both.
MMX, Pentium, and ProShare are trademarks or registered trademarks of Intel Corporation in the United States, other countries, or both.
Microsoft and Windows NT are registered trademarks of Microsoft Corporation in the United States, other countries, or both.
Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.
SET and the SET Logo are trademarks owned by SET Secure Electronic Transaction LLC.
C-bus is a trademark of Corollary, Inc. in the United States, other countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other countries.
Other company, product or service names may be trademarks or service marks of others.

Information is provided "AS IS" without warranty of any kind.

All customer examples described are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual environmental costs
and performance characteristics may vary by customer.

Information in this presentation concerning non-IBM products was obtained from a supplier of these products, published announcement material, or other publicly available sources
and does not constitute an endorsement of such products by IBM. Sources for non-IBM list prices and performance numbers are taken from publicly available information, including
vendor announcements and vendor worldwide homepages. IBM has not tested these products and cannot confirm the accuracy of performance, capability, or any other claims related
to non-IBM products. Questions on the capability of non-IBM products should be addressed to the supplier of those products.

All statements regarding IBM future direction and intent are subject to change or withdrawal without notice, and represent goals and objectives only. Contact your local IBM office or
IBM authorized reseller for the full text of the specific Statement of Direction.

Some information in this presentation addresses anticipated future capabilities. Such information is not intended as a definitive statement of a commitment to specific levels of
performance, function or delivery schedules with respect to any future products. Such commitments are only made in IBM product announcements. The information is presented here
to communicate IBM's current investment and development activities as a good faith effort to help with our customers' future planning.

Performance is based on measurements and projections using standard IBM benchmarks in a controlled environment. The actual throughput or performance that any user will
experience will vary depending upon considerations such as the amount of multiprogramming in the user's job stream, the I/O configuration, the storage configuration, and the
workload processed. Therefore, no assurance can be given that an individual user will achieve throughput or performance improvements equivalent to the ratios stated here.

Photographs shown are of engineering prototypes. Changes may be incorporated in production models.

IBM Confidential until announced. © 2005 IBM Corporation 48

You might also like