Develop Java
portlets
Tutorial Details:
Develop Java portlets
Develop Java portlets
By: By Carl Vieregger
Use iViews to render data from a remote database
aybe you believe the hype: corporate portals belong to the next wave of strategic enterprise applications that will transform the way companies do business. Or maybe you agree with a recent advertisement that proffered the following strategic analysis: portal schmortal. Either way, corporate portals are winning mind share in the boardroom with their promise of frontend, enterprisewide integration. For most corporate portals, this promise is fulfilled by custom-developed application components based on Sun Microsystems' Java 2 Platform, Enterprise Edition (J2EE) Web application model. These portal components?portlets?ultimately deliver business content to users' browsers.
Hands-on portlet development
To date, most vendors have constructed their own APIs and frameworks for portlet development. At the same time, Java Specification Request (JSR) 168 strives to produce a common specification that would enable portlet interoperability between corporate portal applications from different vendors. You can review the details of JSR 168 at the Java Community Process (JCP) Website (see Resources ). The specification's public release is planned for April 2003. Until then, the best sources for Java developers to gain initial experience with portlet development are portal vendors' proprietary APIs.
German software vendor SAP offers an excellent place to start. The SAP offering includes a comprehensive development, deployment, and runtime environment?all of which fit on a modest-sized computer. All of the necessary software is free to download, either from open source projects or directly from SAP. In addition to its ready availability and no-cost startup, SAP has also produced a robust API and development framework for dynamic portlets, which SAP calls iViews.
iViews: Content in the SAP Enterprise Portal
The content in a portlet can include anything from a simple Webpage to a personalized view of complex data in multiple systems. Portals usually don't pretend to offer true backend integration without the support of a complete enterprise application integration (EAI) suite, but they instead enable an integrated view?an iView?of backend information for the user.
In this article's example, I will build a portal component iView that queries a remote database and renders the result within SAP's proprietary framework. Even though it is a simplified version of a customer-specific solution, the example is still relatively complex. While extremely basic HelloWorld and stock ticker examples might provide a simpler start, they ultimately fail to utilize the full range of functionality offered by vendors' APIs. The example iView pictured in Figure 1 displays a list of just-in-time (JIT) electronic data interchange (EDI) calls from the automotive industry.
Figure 1. Example iView of JIT EDI calls from MySQL
The download bundle (see Resources ) that accompanies this article includes the source code for the JIT iView, as well as some additional resources to support the development process.
I used the open source MySQL database server to store the data for the example, but you can work with any Java Database Connectivity (JDBC)-compliant database and driver. The name of the database I created is edi_db , and it contains a single table, jit_calls . While this article does not describe the process to install and set up the example database, the download bundle includes a SQL flat file jit_calls.sql with dummy data, which you can import into MySQL.
Access to the MySQL database system requires authentication with a user ID and password; I created the user mysql_remote with password gcoe . I also assigned a password to the default ODBC@localhost user to eliminate anonymous login. These configuration details are summarized in the sidebar, " MySQL Information for the JIT iView ."
The complete DOS output of table jit_calls, including the full authentication of user mysql_remote, is depicted in Figure 2.
Figure 2. Example data from MySQL. Click on thumbnail to view full-size image.
You have probably worked through the traditional JDBC example covered in Sun's The Java Tutorial (see Resources ). The standard construct accesses a database by passing the user ID and password as clear text in the SQL getConnection() method:
getConnection("jdbc:mysql:///"edi_db","mysql_remote","gcoe");
Instead of explicitly passing the user ID and password, though, the JIT iView employs the SAP portal service for user management, which enables authenticated users in the portal to access remote data sources via single sign-on (SSO). By means of a concept called user mapping , the user in the portal maps to a user ID and password from the backend system. When the portal user accesses the back end, the mapped credentials are sent for authentication without prompting for additional login information. In the example, I map a default user from the portal to the user mysql_remote in the MySQL database system.
Set up the portal landscape
To prepare the portal environment for SSO access to a remote system, you must complete the following three activities:
Set up the development environment
Register the backend system in the landscape settings for the portal
Perform user mapping
Set up the development environment
SAP provides the Portal Development Kit (PDK) as a separate, offline development and deployment platform for Java iViews. The PDK's development environment is based on the Java 2 SDK, and its deployment environment is implemented as a Web component inside an Apache Tomcat servlet container. A set of custom APIs provides a development framework for portal components, and global services enable additional functionality, including access to remote data sources, user management, and easy data rendering in the portal. Java developers who don't have immediate access to a full SAP Enterprise Portal (EP) implementation can also use the PDK to deploy and test their iViews.
SAP also offers add-on wizards for Borland's JBuilder and the open source Eclipse platform. The wizards work to integrate a fully featured IDE with the PDK platform. SAP, however, plans to discontinue support for JBuilder with the portal's next release. For simple portal component projects, I prefer to use Apache Ant as the build tool for my portlet application archives.
After an initial registration, the PDK is freely available from the SAP iViewStudio Webpage (see Resources ). PDK installation inside Tomcat 3.3x or 4.x is described in SAP's "Installation and Administration Guide." When you start Tomcat, the iView Runtime for Java (IRJ) deploys as a Java Web component, and it ultimately serves as the PDK platform. After deployment, the default start page for the PDK is at http://localhost:8080/irj/servlet/prt/portal/, and you can log in with the default user ID wp and password wpuser . To facilitate testing, the PDK's styles and page navigation structure mirror that of a productive SAP EP. Figure 3 depicts the PDK's dancing Welcome page.
Figure 3. The SAP PDK dancing welcome. Click on thumbnail to view full-size image.
As part of the download bundle, I created a custom JavaWorld tab for the PDK. Install the tab by copying the folder {7} JW Tools and all its contents to the directory structure under tomcat\webapps\irj\WEB-INF\plugins\portal\content\. When you refresh the PDK browser, you should have a new tab on the top-level navigation bar. I introduce this tab's components when we first use them in the next section.
Register the backend system
Once the PDK is installed and configured with the custom JavaWorld tab, you must register the MySQL backend system as a portal data source . Information about the different data sources in the portal landscape is maintained in the Systems.xml file, which is located in the tomcat\webapps\irj\WEB-INF\plugins\portal\services\landscape\xml\ folder. By default, the XML file contains many standard SAP entries, and you must add a new system tag for MySQL. (All of the required entries for the JIT iView example are included in the Systems.xml file that is part of the download bundle.) The System name parameter is freely definable, but you must include the UserMappingType attribute exactly as in the example. The attribute value registers the system with the portal's user management service to enable user mapping:
MySQL
After changing the default Systems.xml file, you must upload the modified file to the portal server's persistent layer (the Portal Content Directory (PCD)). Move to the JW Tools tab in the PDK, where the entry page displays the System Landscape Cockpit. The Landscape Upload Status should report that Systems.xml is not uploaded, as shown in Figure 4.
Figure 4. Landscape file Systems.xml is not uploaded
Click on the Upload to Portal button to open the PCD Upload tool on the right side of the cockpit.
Figure 5. The PCD Upload tool in the Systems Landscape Cockpit
Browse to your modified Systems.xml file and upload it (Figure 5). The resulting message should read, "Upload successful: File Systems.xml uploaded to PCD location: /system/landscape/Systems.xml." Refresh the Landscape Upload Status to compare the PCD persistence layer with the IRJ, as shown in Figure 6.
Figure 6. Refresh the System Landscape Service
If the PCD and IRJ are not synchronized, click the Refresh Landscape Service button. The Landscape Upload Status should now report that Systems.xml is uploaded (Figure 7), and it should not report any discrepancies.
Figure 7. Synchronize the persistence layer (PCD) with the runtime (IRJ)
Perform user mapping
As described above, user mapping enables an authenticated portal user to access a remo
Read
Tutorial at: Click here to view the tutorial
Rate Tutorial: Develop Java
portlets
View Tutorial: Develop Java
portlets
Related
Tutorials:
Develop Java
portlets
Develop Java
portlets |
Introducing the Portlet Specification, Part 1
Introducing the Get your feet wet with the specification's underlying terms and concepts |
Introducing the
Portlet Specification, Part 2
Introducing the
Portlet Specification, Part 2 |
libbraille
Libbraille is a computer shared library which makes it possible to easily develop for Braille displays. It provides a simple API to write text on the terminal, directly draw dots, or get the value of keys pressed on the Braille display. |
Capture the benefits of asynchronous logging
Capture the benefits of asynchronous logging
Develop an asynchronous log service using JMS and Hibernate
This article will help you develop a simple log service. The service creates some log messages, sends them across the network to a JMS provider, |
Java Development on Eclipse, Part 2
Java Development on Eclipse, Part 2
Editor's note: In part one of this two-part series of excerpts from Eclipse, author Steve Holzner provided examples of how Eclipse makes it easier to create Java code from scratch. Continuing in that vein, in this we |
Improve on Javadocs with ashkelon
Improve on Javadocs with ashkelon
Sun's Javadocs provide us with automatically generated, hyperlinked documentation of fields, methods, classes, interfaces, and inner classes. They are helpful in many ways, but you will soon develop a wish list that incl |
Clean Up Your Mess: Managing Temp Files in Java Apps
Clean Up Your Mess: Managing Temp Files in Java Apps
Creating and managing temporary files in a Java application can be a little tricky due to some open JVM bugs. Develop a workaround with some custom code and a clever design. |
Portlet Community
Portlet Community
If J2EE based portals, JSR 168 or WSRP mean anything to you, you have come to the right place. |
A well-behaved Jetspeed portlet
This article presents a working example of how to construct a Jetspeed portlet that runs efficiently, adheres to the Model 2 architecture, and, by not interfering with additional portlets, plays well with others. In addition, I demonstrate some simple way |
Develop WAP Applications with Java Servlets and JavaServer PagesTM
WAP, the Wireless Application Protocol, was designed to take advantage of the several data-handling approaches already in use. WAP integrates the Handheld Device Markup Language (HDML) and the Handheld Device Transport Protocol (HDTP) developed by Unwired |
Java Server Pages Dynamically Generated Web Content.
JavaServer PagesTM (JSP TM) technology allows Web developers and designers to rapidly develop and easily maintain, information-rich, dynamic Web pages that leverage existing business systems. |
Tag Libraries Tutorial
This tutorial describes how to use and develop JavaServer Pages tag libraries. The tutorial assumes that you know how to develop servlets and JSP pages and are familiar with packaging servlets and JSP pages into Web application archives. |
Getting Started with Java Message Service (JMS)
The Java Message Service (JMS) is designed to allow Java applications to use enterprise messaging systems. It makes it easy to develop enterprise applications that asynchronously send and receive business data and events. Learn how to implement it for you |
Understanding Network Class Loaders Class loaders
One of the cornerstones of Java dynamics, determine when and how classes can be added to a running Java environment. |
Introduction To Enterprise Java Bean(EJB). WebLogic 6.0 Tutorial.
Introduction To Enterprise Java Bean(EJB). WebLogic 6.0 Tutorial.
Welcome to EJB Section
(Learn to Develop World Class Applications with Enterprise Java Beans)
(Online WebLogic 6.0 Tutorial)
Introduction To Enterprise Java Bean(EJB)
Enterprise |
Very simple `Hello world' java program that prints HelloWorld
Very simple `Hello world' java program that prints HelloWorld
Hello World Java
Simple Java Program for beginners (The HelloWorld.java)
Java is powerful programming language and it is used to develop robust applications. Writing a simple Hello |
Parisonz Solutions!
Parisonz Solutions!
W elcome to Parisonz Solutions . The purpose of this web is to Develop and Distribute Projects to Businesses and Individuals though Web. We have a wide range of projects completed online — including software development, web |
Techniques used for Generating Dynamic Content Using Java Servlets.
Techniques used for Generating Dynamic Content Using Java Servlets.
Techniques used for Generating Dynamic Content
Common Gateway Interface (CGI)
For any web application high performance and timely delivery are key ingredients to competitive |
Running JavaServer Faces Technology-Based Portlets on Sun Java System Portal Server 6 2005Q1
You can extend the framework based on JavaServer Faces technology and then run a JSR 168-compliant portlet on Sun Java System Portal Server 6. This article describes the setup procedures, offers sample code, and summarizes the known issues. |
|
|
|