22.3.4 Running the HRPortlet application

Finally, after creating the portlet project and importing the Java classes, you will run the HRPortlet.

1. Run the HRPortlet portlet by right-clicking HRPortlet in the Project Explorer view and selecting Run | Run on server....

2. In the Define a New Server window, select the Choose an existing server option and for Select the server that you want to use, select WebSphere Portal V5.1 Test Environment @ localhost. Also, use default port 9081.

Note: You can also check the Set server as project default checkbox, so you will not be prompted again when you run the portlet.

3. The portlet executes and you will see it in the built-in browser.
The View mode is shown with a message indicating that you have to provide an SQL query; you will also need to switch the portlet into Edit mode (as indicated in Figure 22-31) so you can enter these values.



Figure 22-31 Portlet initial window

4. In Edit mode, the JSP for this mode renders the form requesting the database parameters. For the first time, enter the following information and select Submit:

- Database: jdbc:db2j:C:\HRproject\database\WSSAMPLE

- User: db2admin

- Password: db2admin

- SQL statement: select * from jobs

Figure 22-32 Portlet in Edit mode

5. Clicking Submit generates a creatEReturnURI and the portlet will return to View mode showing the results of your query against the WSSAMPLE database.

Figure 22-33 Query results

6. Enter Edit mode again. Notice that the database name, user ID, password and SQL statement, which have been stored in session object, are persistent.

Figure 22-34 Database information and SQL query statement

7. Enter a new query, for example select * from survey, and click Submit. You will be presented with the results of your new query.

Figure 22-35 Query results


Redbooks
ibm.com/redbooks