Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Building an Ajax portlet for WebSphere Portal

Karl Bishop (kfbishop@us.ibm.com), Senior Software Engineer, IBM
Photo: Karl Bishop
Karl Bishop is a Senior Software Engineer on the IBM Web Enablement and Support team. He works from the wilds of North Carolina. Karl works on various internal and external portal-based applications, as well as being a strong proponent of Linux based solutions.
(An IBM developerWorks Contributing Author)
Doug Phillips (dougep@us.ibm.com), Advisory Software Engineer, IBM
Doug Phillips is an Advisory Software Engineer for IBM's elite group of skilled professionals known as IBM's Web Enablement and Support team. He has worked in many organizations within IBM and currently designs and develops both internal and external WebSphere Portal applications using IBM middleware and Linux. Doug is WebSphere and DB2 certified.

Summary:  In our previous article, Using Ajax with WebSphere Portal, we discussed some issues and design concerns when using Ajax in a portal application. In this tutorial, we will put our newfound knowledge to use and create an Ajax portlet application. To make things interesting, we decided to build a portlet that makes heavy use of Ajax and DHTML. This provides you a glimpse into what's possible with this technology, and to also give you a useful tool to browse your databases. While most of the application is already written, it is up to you to fill in the blanks to get things running.

Date:  16 Aug 2006
Level:  Intermediate PDF:  A4 and Letter (2104 KB | 37 pages)Get Adobe® Reader®

Activity:  39498 views
Comments:  

Kick starting the code

Now that you have all of the Ajax code in place, it's not going to start by itself. You need to tell the browser that you actually want something to happen when an action is performed. You need to have some JavaScript events coded so the end user can kick off the Ajax calls when the user is interacting with the application. In this section, you will add the "onclick" event to the datasource lookup button.

  1. Locate the init() function in the DBExplorer.js file. Add an event handler for the load data source button by inserting the following code into the script at the lines indicated.
    document.getElementById("datasource_button").onclick =event_setDataSource;

    This tells the browser to execute this function when the button is clicked. We could have added these event listeners directly inside the form input tags, but that is not near as much fun. When adding event listeners using this method, you add the actual function object, and therefore, do not include quotes or the parenthesis. The events for the other fields have already been coded for you. The table below contains the other "onXXX" events that are already coded and need no action by you. You can review these areas of the code if you wish to have a better understanding.

    Input field Event Handler function Action performed
    Data source load button onclick event_setDataSource Retrieves database properties and schema list.
    Schema select onchange event_setSchema Retrieves the table list.
    Table select onchange event_setTable Retrieves available columns.
    Available columns select ondblclick event_addColumn Adds column to active columns list and retrieves table data.
    Active columns select ondblclick event_deleteColumn Removes column from active columns list and retrieves table data.


  2. Save your changes before continuing to the next step by selecting File -> Save from the menu or type Ctrl-S.

9 of 18 | Previous | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=153838
TutorialTitle=Building an Ajax portlet for WebSphere Portal
publish-date=08162006
author1-email=kfbishop@us.ibm.com
author1-email-cc=
author2-email=dougep@us.ibm.com
author2-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.