Tutorial Setup
To prepare the environment for the tutorial, you will create a deployment configuration in WebSphere Portlet Factory, create a database and a table in DB2, and create a datasource in WebSphere Application Server.
WebSphere Portlet Factory—Create a Deployment Configuration
A deployment configuration is a set of properties that define your deployment information. An application server is needed for testing the models in the tutorial and you will create a deployment configuration for the application server instance. Your WebSphere Portal installation has two WebSphere Applications Server instances: server1 and WebSphere_Portal. In this section, you will create a deployment configuration for the WebSphere Application Server instance WebSphere_Portal.
- Start WebSphere Portlet Factory Designer.
- Click Start, All Programs, IBM WebSphere, Portlet Factory, Designer.
- Click OK to accept the default workspace folder as shown in Figure 7.4.
Figure 7.4 Select a workspace
- Create a deployment configuration.
- Click Window, Preferences as shown in Figure 7.5.
Figure 7.5 Set preferences
- Expand the WebSphere Portlet Factory Designer section and click Deployment as shown in Figure 7.6.
Figure 7.6 Select deployment preferences
- Click Add to create the deployment environment for deploying your projects as shown in Figure 7.7.
Figure 7.7 Add a deployment configuration
- Table 7.1 shows you how to provide inputs for the New Deployment Configuration dialog. Click OK when you are finished with the dialog as shown in Figure 7.8. Make sure the WAS server WebSphere_Portal has been started.
Table 7.1. Input values for Deployment Configuration dialog
Parameters
Values
Configuration Name
Enter WAS61 or provide a different name of your choice.
Description
Enter WAS 6.1 deployment configuration or provide your own description.
Server Type
Select WebSphere Application Server 6.x from the drop-down.
Installed Applications Dir
Enter your WebSphere Portal installed directory.
(Example: C:\IBM\WebSphere\wp_profile\installedApps\portalhost).
Server Host
Enter your WebSphere Portal host name.
(Example: portalhost.ibm.com).
Server Port
10040.
Specify Deployment Credentials
Select this check box.
WAS Server for deployment
Select WebSphere_Portal from the drop-down.
Admin User
Enter your WebSphere Portal Administrator user ID.
Admin Password
Enter your WebSphere Portal Administrator password.
Figure 7.8 New Deployment Configuration dialog
- A message indicating that the test to connect to the WAS server was successful is shown as in Figure 7.9. Click OK to close the window.
Figure 7.9 Test connection message
- The new deployment configuration has been created successfully as shown in Figure 7.10. Click OK to close the Preferences window.
Figure 7.10 New deployment configuration successfully created
- Click Window, Preferences as shown in Figure 7.5.
In this setup step, you have created a deployment configuration for deploying your projects.
DB2—Create a Database and a Table
This is a setup step required by Tutorial 7.2.
- Start the DB2 Control Center.
- Click Start, All Programs, IBM DB2, DB2COPY1 (Default), General Administration Tools, Control Center.
- Advanced view is the default for the Control Center View as shown in Figure 7.11. Simply click OK.
Figure 7.11 Specify Control Center view
- Create a database using the Create Database Wizard.
- Right-click All Databases and click Create Database, Standard as shown in Figure 7.12.
Figure 7.12 Invoke Create Database Wizard
- Enter PetDB as the database name, and keep all other defaults as shown in Figure 7.13. Click Finish.
Figure 7.13 Specify database name
- Right-click All Databases and click Create Database, Standard as shown in Figure 7.12.
- Create a database table using the Create Table Wizard.
- After database PetDB is created successfully, you are returned to the Object view. You should be able to see PetDB by expanding All Databases. To invoke the Create Table Wizard, expand PetDB. Then right-click Tables and click Create as shown in Figure 7.14.
Figure 7.14 Invoke Create Table Wizard
- Enter PetTravelCompany as the table name as shown in Figure 7.15. Click Next.
Figure 7.15 Specify table name
- Click Add to add a column to the PetTravelCompany table as shown in Figure 7.16.
Figure 7.16 Add a column
- Enter ID as the column name and select INTEGER from the drop-down for data type as shown in Figure 7.17. Click OK.
Figure 7.17 Add Column dialog
- Use the Add button to add two more columns using the Table 7.2 as inputs.
Table 7.2. Inputs values for add column dialog
Column Name
Data Type
Length
Company
VARCHAR
50
Desc
VARCHAR
100
-
PetTravelCompany has three columns added as shown in Figure 7.18. Click Finish.
Figure 7.18 Column definition
- A message indicating that the table creation was successful is shown as in Figure 7.19. Click Close.
Figure 7.19 Table successfully created
- To display the list of tables in the Contents pane, right-click Tables and click Refresh as shown in Figure 7.20. Do you see your newly created table PetTravelCompany in the Contents pane on the right side?
Figure 7.20 Refresh the list of tables
- After database PetDB is created successfully, you are returned to the Object view. You should be able to see PetDB by expanding All Databases. To invoke the Create Table Wizard, expand PetDB. Then right-click Tables and click Create as shown in Figure 7.14.
- Add data to a database table.
- To add data to the table PetTravelCompany, right-click PETTRAVELCOMPANY and click Open. as shown in Figure 7.21
Figure 7.21 Open a table
- Click Add Row to add a row to the table as shown in Figure 7.22. You will be doing this action four times to add four rows.
Figure 7.22 Add a row
- Use table 7.3 as input when adding the four rows to the table.
Table 7.3. Input values for Add Rows
ID
COMPANY
DESC
1
AA
Pet travel insurance
2
BB
Pet carrier for dogs
3
CC
Pet friendly accommodation
4
DD
Pet sitting while you travel
- When all the rows have been added to the table, click Commit and then Close as shown in Figure 7.23.
- To add data to the table PetTravelCompany, right-click PETTRAVELCOMPANY and click Open. as shown in Figure 7.21
Figure 7.23 Table content
In this setup step, you have created a database and a table for creating a portlet that accesses a database.
WebSphere Application Server—Create a Datasource
This is a setup step required by Tutorial 7.2.
- Log in to WebSphere Application Server administration console.
- Start the WebSphere Application Server administration console by opening a browser and entering the uniform resource locator (URL) http://<hostname>:<port_number>/ibm/console, where <hostname> is the fully qualified host name of the machine that is running your WebSphere Portal and <port_number> is the administration console port number. For example, enter http://portalhost.ibm.com:10027/ibm/console
- Log in using your administrator user ID and password.
- Select the JDBC (Java Database Connectivity) provider.
- Expand Resources, JDBC and click JDBC Providers as shown in Figure 7.24.
Figure 7.24 Go to the list of JDBC providers
- Click wpdbJDBC_db2 as shown in Figure 7.25.
Figure 7.25 Select the JDBC provider for the portal
- Expand Resources, JDBC and click JDBC Providers as shown in Figure 7.24.
Create a datasource.
- Under Additional Properties, click Data Sources as shown in Figure 7.26.
Figure 7.26 Go to the list of datasources
- To invoke the Create a Data Source Wizard, click New as shown in Figure 7.27. You will be creating a datasource for your database PetDB.
Figure 7.27 Invoke the Create a New Data Source Wizard
- In Step 1 of the Create a Data Source Wizard as shown in Figure 7.28, enter PetDB for the datasource name, jdbc/PetDB for the JNDI name, and select wpdbDSJAASAuth for the authentication alias. Click Next.
Figure 7.28 Step 1 of the Create a Data Source Wizard
- In Step 2 of the Create a Data Source Wizard as shown in Figure 7.29, enter PetDB for the database name and your WebSphere Portal host name for the server name. An example of a host name is portalhost.ibm.com. Click Next.
Figure 7.29 Step 2 of the Create a Data Source Wizard
- In Step 3 of the Create a Data Source Wizard as shown in Figure 7.30, simply review the information. Click Finish.
Figure 7.30 Step 3 of the Create a Data Source Wizard
- Click the Save Directly to the Master Configuration link as shown in Figure 7.31.
Figure 7.31 Save to master configuration
In this setup step, you created a datasource for database PetDB.
- Under Additional Properties, click Data Sources as shown in Figure 7.26.