Tutorials – Getting Started with WebLogic Portal

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Creating a Portal in Your Development Environment

This tutorial helps you learn how to create a portal and portlets using WebLogic Portal in the Workshop for WebLogic workbench. For m ore detailed information about each dialog of the wizards used in this chapter, refer to the Portal Development Guide.


Before You Begin

The tasks described in this chapter are based on those described in Setting Up Your Portal Development Environment, so it is important that you complete that tutorial before starting the tasks described here.


Tutorial Steps

Using the tutorial, you will create a portal and two portlets, create an additional page for the portal, and then place the portlets onto a page of the portal.

The tutorial includes instructions on how to perform these tasks:

Create a Portal

In this task you will create a portal for the project that you created in Create a Portal Web Project.

To create a portal, perform these steps:

  1. If the Portal perspective is not already open, select it by choosing Window > Open Perspective > Portal.
  2. Using the Portal perspective is optional, but the instructions and figures in this tutorial are based on the views that are available in the Portal perspective.

  3. Navigate to the myPortalWebProject/WebContent directory, right-click and then select New > Portal.
  4. The New Portal dialog displays, as shown in Figure 3-1.

    Because you started this wizard by right-clicking the web content directory, the parent folder field automatically displays that directory name.

    Figure 3-1 New Portal Dialog

    New Portal Dialog

    As a best practice, you should locate your portal file in a web content directory that is subordinate to the web project directory. The default web content directory name is WebContent, and is assigned when you use the Portal Web Project Wizard. You can change the name of your web content directory if you wish; for more information, refer to the Portal Development Guide.

  5. In the File name field, enter myPortal.
  6. A file type of .portal is required for portals; you can type the .portal extension to the portal’s name if you wish, but WebLogic Portal automatically adds the extension if you don’t enter it.

  7. Click Finish.
  8. The wizard adds myPortal.portal to the WebContent folder in the Portal web project and a view of the portal displays in the workbench, as shown in Figure 3-2.

    Figure 3-2 Portal Displayed in Workbench

    Portal Displayed in Workbench

The created portal includes a desktop, header, footer, book, and page. A desktop is a user-specific view of the portal content. A portal can support many desktops. A single portal might support an employee-specific desktop, a customer-specific desktop, and others, where each desktop exposes different kinds of content to different sets of users. Any part of a portal can be included or excluded from a desktop, including a book, a page, a specific application, or an individual link.

Desktops can also define the look and feel attributes of a Portal. Desktops can be associated with a particular skin that defines the color scheme, fonts, and images used. Desktops also contain a header and footer—you can place images, text, or any web content in these areas to give consistency to the look and feel of a desktop.

You use books to organize your content and navigation in a hierarchical manner. Books can contain other books or pages. In a browser, a book is rendered as a set of tabs or links. Each portal contains a main book called, by default, “Main Page Book.” A page consists of a set of columns and/or windows that organize the actual content of your portal. You navigate to a page by clicking on an individual tab or a link.

Add a Page to Your Portal

In this task you will add a second page to the portal’s main book. When the portal is rendered in a browser, the two pages will appear as two clickable tabs. You add a new page by dragging and dropping the new page into the main work area. You will also set properties on the new page using the Properties view.

To add a new portal page, perform these steps:

  1. From the Design Palette view, drag and drop the Page icon to the area directly to the right of the Page 1 tab. Figure 3-3 shows the result when you release the mouse button.
  2. Tip: If you do not see the Design Palette tab, select Window > Show View > Design Palette.
    Figure 3-3 Adding a Page to a Portal in the Workbench

    Adding a Page to a Portal in the Workbench

The new page has a default title of “New Page.” To change it, perform these steps:

  1. Click the new page tab to select it.
  2. In the Properties view, enter “Page 2” as the new title, as shown in Figure 3-4.
  3. When you enter the new value, the editor shows that the title has changed from New Page to Page 2.

    Figure 3-4 Changing a Page Title in the Workbench Properties View

    Changing a Page Title in the Workbench Properties View

  4. Save your changes.

Deploy and View Your New Portal

This portal isn’t very interesting yet, but as a quick test, you will deploy your new portal to the server and view it in a browser window that is contained within Workshop for WebLogic.

Follow these steps:

  1. Right-click myPortal.portal in the Package Explorer view and select Run As > Run on Server, as shown in Figure 3-5.
  2. Figure 3-5 Selecting to Run the Portal on the Server

    Selecting to Run the Portal on the Server

    The Run On Server - Define a New Server dialog displays. Make sure the server that you created during the previous WebLogic Portal tutorial task is highlighted.

    Tip: When you select Run On Server, the portal web application is automatically published. Publishing involves copying project files, such as resource and configuration files, to the correct location for the server to locate and use them. Workshop for WebLogic detects whenever a file changes that requires republishing. When this happens, the state of the server changes to Republish. (You can see this reflected in the Servers view.) To republish the application, you can right-click the server in the Servers view and select Publish, select the Publish icon, or select the portal in the Project view and pick Run As > Run On Server.
  3. Click Finish to begin the deployment process.
  4. Wait while Workshop for WebLogic starts the server, deploys files to the server, and runs the application. While deployment is in process, you can view status messages in the status bar at the bottom of the window.

    The results appear in a new tab in the editor view, as shown in Figure 3-6.

    Figure 3-6 Portal Display in the Workbench Editor View

    Portal Display in the Workbench Editor View

    Leave this new tab open; after you add portlets you will refresh this display to view them.

    Tip: You can choose to always use an external web browser to view your portal if you wish. To do so, select Window > Preferences and select General > Web Browser in the property tree; then select the Use external Web browser radio button and pick a browser type from the list. If no browsers appear in the list you can search for available browsers and add them to the list.

Create Portlets

In this task you will create two portlets: a Browser URL portlet and a simple JSP portlet.

Create a Folder to Contain the Portlets

To organize your portlets, it’s a good idea to store them in a subfolder in your web content directory.

To create a portlet folder, follow these steps:

  1. Right-click the WebContent directory and select New > Folder.
  2. The New Folder dialog displays, as shown in Figure 3-7.

    Figure 3-7 New Folder Dialog - Create Folder for Portlets

    New Folder Dialog - Create Folder for Portlets

  3. Type the folder name portlets and click Finish.

Create a Browser URL Portlet

Browser portlets, also called Content URL portlets, are basically HTML portlets that use URLs to retrieve their content. Unlike other portlet types that are limited to displaying data contained within the portal project, browser portlets can display URL content that is outside the portal project.

To create the browser portlet, perform these steps:

  1. Right-click the portlets folder and select New > Portlet.
  2. The New Portlet dialog displays, as shown in Figure 3-8. The folder for the portlet displays automatically in the parent folder field.

    Figure 3-8 New Portlet Dialog

    New Portlet Dialog

    The Finish button is initially disabled; the button enables when you select a valid parent folder and type a portlet name. If you select an invalid portal project in the folder tree on this dialog, an error message appears in the status area near the top of the dialog explaining that the project is not a valid portal project.

  3. Type myBrowserPortlet as the file name for the new portlet.
  4. Click Next.
  5. The Portlet Wizard displays the Select Portlet Type dialog.

  6. Click Browser (URL) Portlet and then click Next.
  7. The Portlet Wizard displays the Portlet Details dialog; Figure 3-9 shows an example.

    Figure 3-9 Creating a Browser URL Portlet - Portlet Details Dialog

    Creating a Browser URL Portlet - Portlet Details Dialog

  8. Specify the values for this portlet, using Table 3-1 as a guide.
  9. Table 3-1 Portlet Wizard - Browser Portlet Data Entry Fields
    Browser Portlet
    This value appears in the title bar of the portlet in the editor view of the Workshop for WebLogic workbench.
    Content URL
    This is the value for the Content URL (external URL) that the portlet should use to retrieve its information.
    Has Titlebar
    Leave the box checked.
    In order for a portlet to have changeable states or modes, the portlet must have a title bar.
    Select all four check boxes: Minimizable, Maximizable, Floatable, and Deleteable.
    Available Modes
    Leave these fields blank.

  10. Click Create.
  11. The Workshop for WebLogic window updates, adding the myBrowserPortlet.portlet file to the portlets folder and displaying the new portlet in the editor, as shown in Figure 3-10.

    Figure 3-10 New Browser Portlet Displayed in Editor

    New Browser Portlet Displayed in Editor

Create a JSP Portlet

JSP portlets reference JSP files. In most cases you can reuse existing JSP files to build portlets from them. JSP portlets are recommended when the portlet is simple and does not require the implementation of complex business logic.

In this task, you will create a simple JSP file and then use that file to generate a portlet.

Follow these steps:

  1. Double click the file index.jsp in the Package Explorer view.
  2. The index.jsp file is located in the WebContent directory, and is included with any Portal Web Project that you create.

    The source code for the file displays in an editor view. Select the Source tab just below the source code window to display just the source code.

  3. Change the default body text to Simple JSP Portlet as shown in Figure 3-11.
  4. Figure 3-11 JSP File Showing Edited Body Text

    JSP File Showing Edited Body Text

  5. Select File > Save As and save this JSP file as jsp_portlet.jsp.
  6. Drag the jsp_portlet.jsp file into the portlets folder.
  7. Right-click jsp_portlet.jsp and select Generate Portlet from the menu.
  8. Because you are generating a portlet from an existing .jsp file, the Portlet Wizard goes directly to the Portlet Details dialog; Figure 3-12 shows an example.

    Figure 3-12 Portlet Wizard - JSP Portlet Details Dialog

    Portlet Wizard - JSP Portlet Details Dialog

  9. Specify the values specified in Table 3-2.
  10. Table 3-2 Portlet Wizard - JSP Portlet Data Entry Fields
    Simple JSP Portlet
    Content Path
    Because you are creating this portlet based on an existing JSP file, WebLogic Portal automatically fills in this value.
    Has Titlebar
    Leave this box checked.
    Select the check boxes Minimizable and Maximizable.

  11. Click Create.
  12. The Workshop for WebLogic window updates, adding the jsp_portlet.portlet file to the portlets folder.

Checkpoint: Your WebContent directory should look like the example shown in Figure 3-13.

Figure 3-13 WebContent Directory Including Portal, Browser Portlet, and JSP Portlet

WebContent Directory Including Portal, Browser Portlet, and JSP Portlet

Add Portlets to the Portal and View the Result

In this task you will add your new portlets to the portal and view your changes.

Follow these steps:

  1. In the editor, click the myPortal.portal tab to display it.
  2. Click the Page 1 tab in the portal to select it.
  3. Drag the JSP portlet (with the file name jsp_portlet.portlet) onto the left column (placeholder) of the portal page.
  4. Drag the Browser portlet (with the file name myBrowserPortlet.portlet) onto the right placeholder of the portal page.
  5. Your result should look like the example in Figure 3-14.

    Figure 3-14 Portal in Editor View with Portlets Added

    Portal in Editor View with Portlets Added

  6. Save your change.

To view the new portlets in a browser, follow these steps:

  1. Click to select the New Portal Desktop tab in the editor view.
  2. On the toolbar, click Refresh Portal in Editor View with Portlets Added.
  3. Because your change does not require redeploying the change to the server, you do not need to select the Run on Server option to see the new portlets.

    Your updated portal should look like the example shown in Figure 3-15.

    Figure 3-15 Running Portal with Browser Portlet and JSP Portlet Added

    Running Portal with Browser Portlet and JSP Portlet Added



With the completion of this tutorial, you have created a portal, added a portal page, and created two new portlets that can be displayed in the portal. These components are created on your file system in your current workspace.

To learn about creating desktops using the WebLogic Portal Administration console, continue to Assembling a Desktop in Your Staging Environment.

  Back to Top       Previous  Next