- Product Overview
- How Do They Support SOA?
- Tutorial Overview
- What Is Included in the CD-ROM?
- Tutorial Setup
- Tutorial 7.1: Create and Test a Simple Portlet
- Tutorial 7.2: Create and Test a Portlet That Accesses a Database
- Tutorial 7.3: Deploy a Portlet
- Summary
Tutorial 7.1: Create and Test a Simple Portlet
In this tutorial, you will create a project for all the models that will be built in Tutorials 7.1 and 7.2. You will then create a simple portlet.
Step 1: Create a Project in IBM WebSphere Portlet Factory
In this step, you will create a project in Portlet Factory Designer.
- Launch the Create Portlet Factory Project Wizard to create a WebSphere Portlet Factory project.
- WebSphere Portlet Factory Designer should have been started in the "Tutorial Setup" section.
- Click File, New, WebSphere Portlet Factory Project to create a project as shown in Figure 7.32.
Figure 7.32 Create a WebSphere Portlet Factory project
- Enter PetTravel for the project name. Click Next as shown in Figure 7.33.
Figure 7.33 Enter the project name
- There is no need to add feature sets to your project as shown in Figure 7.34. These feature sets provide additional builders that are not needed for this tutorial. Click Next.
Figure 7.34 Select feature sets
- Select WAS61 from the drop-down for application server deployment configuration as shown in Figure 7.35. Click Finish.
Figure 7.35 Specify application server deployment configuration
- After the progress indicator, click No when asked whether you would like to deploy your project now as shown in Figure 7.36. You will be shown how to deploy your project in a development environment in a separate step.
Figure 7.36 Deployment Request dialog
- Your project PetTravel has been created successfully and appears in the Project Explorer window as shown in Figure 7.37.
Figure 7.37 Project created
You have successfully created the project.
Step 2: Create and Test a Simple Portlet
In this step, you will create a simple model. You will then test the model using the deployment configuration you created in the setup section.
- Launch the WebSphere Portlet Factory Model Wizard to create a Main and Page model. It is one of the sample models provided by the IBM WebSphere Portlet Factory product. A Main and Page model supplies a page and a main action that presents that page when the application is run.
- Right-click PetTravel and click New, WebSphere Portlet Factory Model as shown in Figure 7.38.
Figure 7.38 Create a new WebSphere Portlet Factory model
- Select PetTravel as the project as shown in Figure 7.39. Click Next.
Figure 7.39 Select the project to contain the model
- Under Factory Starter Models, select Main and Page as shown in Figure 7.40. Click Next.
Figure 7.40 Select to create a Main and Page model
- Keep all the defaults as shown in Figure 7.41. Click Next.
Figure 7.41 Specify page type
- Enter PetTravelFAQ as the model name as shown in Figure 7.42. Click Finish.
Figure 7.42 Specify the model name and save
- Right-click PetTravel and click New, WebSphere Portlet Factory Model as shown in Figure 7.38.
- Modify the content of the HTML page in the model.
- The PetTravelFAQ model has been created successfully as shown in Figure 7.43. The outline window at the bottom shows the list of builders in this model. Double-click the imported page builder page1.
Figure 7.43 Main and Page model created
- Click Edit Page to modify the page content in HTML as shown in Figure 7.44.
Figure 7.44 Edit page
- To modify the page content, follow the example as shown in Figure 7.45 or provide your own HTML content. Click Save Page, then Apply and OK to save changes for the builder.
Figure 7.45 Modify page content and save builder changes
- Click File, Save to save changes for the model as shown in Figure 7.46.
Figure 7.46 Save model changes
- The PetTravelFAQ model has been created successfully as shown in Figure 7.43. The outline window at the bottom shows the list of builders in this model. Double-click the imported page builder page1.
- Deploy the project for development testing.
- Right-click PetTravel and click Application Server WAR, Build WAR for Dev Testing as shown in Figure 7.47.
Figure 7.47 Deploy project for development testing
- Right-click PetTravel and click Application Server WAR, Build WAR for Dev Testing as shown in Figure 7.47.
- Test the model.
- Click the Run Active Model icon as shown in Figure 7.48.
Figure 7.48 Run selected model
- A little setup is needed for the first time. Expand WebSphere Portlet Factory Model and select Active Model as shown in Figure 7.49. Click Run.
Figure 7.49 Run setup
- Your model should run successfully. The page you provided HTML content for is shown in a browser as in Figure 7.50.
Figure 7.50 Main and page model successfully run
- Click the Run Active Model icon as shown in Figure 7.48.
- It is simple to make this model run as a portlet as well. Only one builder needs to be added.
- In the outline window, click the Add a Builder Call to the Current Model icon as shown in Figure 7.51.
Figure 7.51 Add a builder call
- In the Builder Picker window as shown in Figure 7.52, select Portal Integration for the category name and Portlet Adapter for the builder. Click OK.
Figure 7.52 Select a builder to add to the model
- Enter PetTravelInfo as the name and the portlet title. Enter Pet Travel Information as the portlet short title. Click Apply and then OK as shown in Figure 7.53.
Figure 7.53 Fill in information for the Portlet Adapter builder
- The Portlet Adapter builder has been added to the model as shown in Figure 7.54. Click File, Save.
Figure 7.54 The Portlet Adapter builder added to model
- In the outline window, click the Add a Builder Call to the Current Model icon as shown in Figure 7.51.
- You only need to do this step if you will not be doing the next section to create and test a portlet that accesses a database. Right-click PetTravel and click Portal Server WAR, Build Portlet WAR for Production Deployment. Keep the defaults. Click Finish.
You have created and tested the model. The model is used to generate the portlet.