Portlet Development Guide

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

Building Portlets

This chapter describes the most common ways to create portlets, including the Portlet Wizard and the use of out-of-the-box portlets. This chapter also contains instructions for building each type of portlet that is supported by WebLogic Portal.

Before you begin, be sure you are familiar with the concepts associated with creating portlets, as described in Understanding Portlet Development.

This chapter contains the following sections:

 


Supported Portlet Types

The following portlet types are supported by WebLogic Portal:

For a detailed discussion of each portlet type, refer to Portlet Types.

 


Portlets in J2EE Shared Libraries

You can copy portlets or other resources from a J2EE Shared Library into your portal application and modify them as needed. A portlet existing in your project will supersede a portlet of the same name in a J2EE Shared Library. To see a list of available portlets, you can use the Merged Projects View of the workbench; resources contained in J2EE Shared Libraries are shown in italic print. You can expand the tree to see the resources that are stored in the various modules. For a reference list of all the J2EE Libraries and their locations on your file system, you can select Window > Preferences > WebLogic > J2EE Libraries.

After you locate a portlet that you want to use, you can right-click the portlet in the Merged Projects View and select the Copy to Project option. Figure 5-1 shows an example of a J2EE Shared Library portlet in the Merged Projects view with the Copy to Project option selected.

Caution: Portlets that are part of the GroupSpace sample application cannot be used in a non-GroupSpace-enabled application.
Caution: If you copy J2EE Shared Library resources into your project, keep in mind that with future updates to the WebLogic Portal product, you might have to perform manual steps in order to incorporate product changes that affect those resources. With any future patch installations, WebLogic Portal supports only configurations that do not have copied J2EE library resources in the project.
Figure 5-1 Portlet Being Copied to a Project from Merged Projects View

Portlet Being Copied to a Project from Merged Projects View

For more information about J2EE Shared Libraries, refer to the Portal Development Guide.

 


Portlet Wizard Reference

An important tool that you can use to create portlets from scratch is the WebLogic Portal Portlet Wizard. The following sections describe the Portlet Wizard in detail:

In general, you choose the portlet type on the first dialog of the wizard; when generating a portlet based on an existing resource, the Portlet Wizard automatically detects the portlet type whenever possible.

Order of Creation - Resource or Portlet First

This section provides an overview of the two methods you can use to begin creating a portlet—creating the portlet resource information/file first or creating the portlet itself first.

Creating the Resource First

You might already have a JSP file, for example, that you want to use as the basis for a portlet. (In addition to JSP files, you can drag other resources onto the portal (such as content selectors) to automatically start the portlet wizard.)

If you have an existing resource that you want to use as the basis of a portlet, follow these steps:

  1. Create or open a portal's .portal file in WorkSpace Studio.
  2. Drag the resource, such as a JSP file, into one of the portal's placeholder areas in the design view in the editor.
  3. WorkSpace Studio prompts you with a dialog similar to the example in Figure 5-2.

    Figure 5-2 Portlet Wizard Prompt Following Drag and Drop of a Resource


    Portlet Wizard Prompt Following Drag and Drop of a Resource

    If you click Yes, the Portlet Wizard uses information from the resource file to begin the process of creating a portlet, and displays the Portlet Details dialog. Figure 5-3 shows an example:

    Figure 5-3 Example Portlet Wizard Details Dialog Following Drag and Drop of a Resource


    Example Portlet Wizard Details Dialog Following Drag and Drop of a Resource

Create the Portlet First

If you do not have an existing source file to start with, you can create the portlet using the New Portlet dialog and the Portlet Wizard. To do so, right-click a folder in your portal web project and select New > Portlet. Figure 5-4 shows an example of the New Portlet dialog.

Figure 5-4 Portlet Wizard New File Dialog

Portlet Wizard New File Dialog

After you confirm or change the parent folder, name the portlet, and click Finish, the Portlet Wizard begins and displays the Select Portlet Type dialog. Figure 5-5 shows an example dialog.

Detailed instructions for creating each type of portlet are contained in How to Build Each Type of Portlet.

Figure 5-5 Portlet Wizard - Select Portlet Type Dialog

Portlet Wizard - Select Portlet Type Dialog

Starting the Portlet Wizard

WorkSpace Studio invokes the Portlet Wizard any time you perform one of these operations:

New Portlet Dialog

When you use File > New > Portlet to create a new portlet, a New Portlet dialog displays before the Portlet Wizard begins. Figure 5-4 shows an example of the New Portlet dialog.

The parent folder defaults to the location from which you selected to add the portlet.

This dialog requires that you select a project and directory for the new portlet, and provide a portlet file name. (The file name appears in the Package Explorer view after you create the portlet.) The Finish button is initially disabled; the button enables when you select a valid project/directory and 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. You cannot continue until you have selected a valid project (if one is available).

Note: With WebLogic Portal Version 9.2 and later versions, the option to convert a non-portal project to a portal project is not offered. For information on how to integrate portal J2EE Shared Libraries into an already existing project, see the Portal Development Guide.

Select Portlet Type Dialog

When the Portlet Wizard starts, it determines the valid portlet types to offer on the Select Portlet Type dialog, based on the type of project that you are working in.

For example, if you are working within a Portal Web Project that has only the WSRP-Producer feature (and its required accompanying features) installed, it does not have the full set of portal libraries. In this case, only the JPF, JSF, Browser, and Struts portlet types are valid selections; the other portlet types are not included in the Select Portlet Type dialog.

If no valid portlet types exist based on the project type, an informational message displays.

Figure 5-8 shows an example of the Select Portlet Type dialog.

Figure 5-8 Portlet Wizard - Select Portlet Type Dialog

Portlet Wizard - Select Portlet Type Dialog

Tip: The Java Server Faces (JSF) Portlet selection only appears by default if you have added the JSF Project facet to you portal web project. In some cases, you may wish to manaully install the modules that are required to create JSF portlets. Although this method is not recommended, if you manually install the appropriate modules, you can force the JSF portlet option to appear in the dialog by selecting Show All Portlet Types. For more information on JSF portlets, see JSF Portlets. .

The Show All Portlet Types option forces all portlet types to appear in the Select Portlet Type dialog even if their modules were not installed. For example, the Java Server Faces (JSF) Portlet selection only appears by default if you have added the JSF Project facet to your portal web project. In some cases, you may wish to manaully install the modules that are required to create JSF portlets. Although this method is not recommended, if you manually install the appropriate modules, you can force the JSF portlet option to appear in the dialog by selecting Show All Portlet Types. For more information on JSF portlets, see JSF Portlets.

WARNING: If you create and publish portlets that require modules that have not been properly installed, unexpected behavior and server runtime errors can occur.

Portlet Details Dialogs

The Portlet Details dialogs that display after you select a portlet type vary according to the type of portlet you are creating. The portlet-building tasks that are described in How to Build Each Type of Portlet contain detailed information about each data entry field of the portlet details dialogs.

 


How to Build Each Type of Portlet

The following sections describe how to create each type of portlet supported by WebLogic Portal:

JSP and HTML Portlets

JSP portlets are very similar to simple JSP files. In most cases you can use existing JSP files to build portlets from them. JSP portlets are recommended when the portlet is simple and doesn’t require the implementation of complex business logic. Also, JSP portlets are ideally suited for single page portlets.

There are several ways to invoke the Portlet Wizard, as explained in the section Starting the Portlet Wizard. This description assumes that you create a portlet based on an existing JSP file.

To create a JSP portlet, follow these steps:

  1. Right-click a JSP file and select Generate Portlet from the menu.
  2. The Portlet Wizard displays the Portlet Details dialog; Figure 5-9 shows an example.

    Figure 5-9 Portlet Wizard - JSP Portlet Details Dialog


    Portlet Wizard - JSP Portlet Details Dialog

  3. Specify the values you want for this portlet, following the guidelines shown in Table 5-1.
  4. Table 5-1 Portlet Wizard - JSP Portlet Data Entry Fields
    Field
    Description
    Title
    The value for the Title might already be filled in.You can change the value if you wish.
    Content Path
    The value for the Content URI (location of the JSP) is probably already filled in. You can change this value if you wish either by entering the path to a JSP or browsing to it. You can also create a new JSP on the fly either by entering a name in the field or by choosing the New button.
    Error Page Path
    To designate a default error page to appear in case of an error, check the box and indicate the path to the desired URI. You can also create a new JSP on the fly either by entering a name in the field or by choosing the New button.
    Has Titlebar
    If you want your portlet to have a title bar, check this box. The displayed title matches the value in the Title field. In order for a portlet to have changeable states or modes, the portlet must have a title bar.
    State
    Select the desired check boxes to allow the user to minimize, maximize, float, or delete the portlet. For a more detailed description of portlet states, refer to Portlet States.
    Available Modes
    You can enable access to Help from the portlet or you can allow the user to edit the portlet.
    To enable an option, select the desired check box and provide the path to the JSP page that will provide the appropriate function. For a more detailed description of portlet modes, refer to Portlet Modes.

  5. Click Create.
  6. The WorkSpace Studio window updates, adding the Portlet_Name.portlet file to the display tree; by default, WorkSpace Studio places the portlet file in the same directory as the content file.

Java Portlets

Java portlets are based on the JSR 168 specification that establishes rules for portlet portability. Java portlets are intended for software companies and other enterprises that are concerned with portability across multiple portlet containers.

WebLogic Portal provides capabilities for Java portlets beyond those listed in the JSR168 spec. For example, you can set threading options, use a backing file, and so on. To implement these additional features, WebLogic Portal uses a combination of the typical .portlet file—which you create in the same way that you create other portlet types—as well as the standard portlet.xml file and the weblogic-portlet.xml file.

Building a Java Portlet

To create a Java portlet, follow these steps:

  1. Right-click the folder where you want to store the portlet and select New > Portlet.
  2. The New Portlet dialog displays.

  3. Enter a name for the portlet and click Create.
  4. The Portlet Wizard displays the Select Portlet Type dialog.

  5. Select the Java Portlet radio button and click Next.
  6. The Java Portlet Details dialog displays. Figure 5-10 shows an example.

    Figure 5-10 Portlet Wizard - Java Portlet Details Dialog


    Portlet Wizard - Java Portlet Details Dialog

  7. Identify whether you want to create a new portlet or update an existing portlet (as an entry in the portlet.xml file) by selecting the appropriate radio button.
  8. If you are creating a new portlet, WebLogic Portal uses the information that you enter in the wizard to perform these two tasks:

    • Create a new .portlet file
    • Either create a new portlet.xml file (if this is the first Java portlet that you are creating in the project), or add an entry in the portlet.xml file, which is located in the WEB-INF directory.
    • If you choose to refer to an existing portlet in the wizard, the wizard displays a selection for every entry in the portlet.xml file, allowing you to create a new .portlet file and associate it with an existing entry in the portlet.xml file.

  9. Specify the values you want for this portlet, following the guidelines shown in Table 5-2. All fields are required.
  10. Table 5-2 Portlet Wizard - Java Portlet Data Entry Fields
    Field
    Description
    New Portlet –
    Title
    The value for the Title maps to the <title> element in the file portlet.xml. The title in the .portlet file takes priority over the one in the portlet.xml file.
    New Portlet –
    Definition Label
    This value acts as the definition label for any portlet; more importantly, the value maps to the <portlet-name> element in the portlet.xml deployment descriptor. This value must be unique.
    New Portlet –
    Class Name
    Enter a valid class name or click Browse to navigate to the location of a Java class. This value maps to the <portlet-class> element.
    If you enter a javax.portlet.Portlet class that does not currently exist, the wizard will create the corresponding .java file when you click Create.
    Existing Portlet – Select From List
    The dropdown menu is populated from the portlet.xml file and contains the values from the <portlet-name> elements.
    When you select an existing portlet, the Title and Class Name display in read-only fields.

    Note: If you import an existing Java portlet into WorkSpace Studio, you do not need to add an entry in the web.xml file for the WebLogic Portal implementation of the JSR-168 portlet taglib; this taglib is declared implicitly. Be sure to use http://java.sun.com/portlet as the taglib URI in your JSPs.

  11. Click Create.
  12. Based on these values that you entered, the Wizard creates a .portlet file, and adds an entry to /WEB-INF/portlet.xml, if it already exists, or creates the file if needed.

    WorkSpace Studio displays the newly created portlet and its current properties. Figure 5-11 shows an example of a Java portlet’s appearance and properties.

    Figure 5-11 Java Portlet Appearance and Properties


    Java Portlet Appearance and Properties

The portlet-name attribute in the portlet.xml file matches the definitionLabel property in the .portlet file.

After you create the portlet, you can modify its properties in the Properties view, or double-click the portlet in the editor to view and edit the generated Java class.

Note: If you delete a .portlet file, the corresponding entry remains in the portlet.xml file. You might want to clean up the portlet.xml file periodically; these extra entries do not cause problems when running the portal but do result in error messages in the log file.

Java Portlet Deployment Descriptor

The separate portlet.xml deployment descriptor file for Java portlets is located in the WEB-INF directory. In addition, the weblogic-portlet.xml file is an optional BEA-specific file that you can use to inject some additional features.

Listing 5-1 shows an example of how entries might look in the portlet.xml file:

Listing 5-1 Example of a portlet.xml file for a Simple Hello World Java Portlet

<?xml version="1.0" encoding="UTF-8"?>
<portlet-app version="1.0"
   xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <portlet>
      <description>Description goes here</description>
      <portlet-name>helloWorld</portlet-name>
      <portlet-class>aJavaPortlet.HelloWorld</portlet-class>
      <portlet-info><title>Hello World!</title></portlet-info>
      <supports>
         <mime-type>text/html</mime-type>
         <portlet-mode>view</portlet-mode>
      </supports>
      <portlet-info><title>new Java Portlet</title></portlet-info>
   </portlet>
</portlet-app>

Importing and Exporting Java Portlets for Use on Other Systems

WebLogic Portal produces Java portlets that conform to the JSR 168 specification and can be used universally across operating systems. WorkSpace Studio lets you export Java portlets to a supported archive file (WAR, JAR, or ZIP) that can be deployed on any supported server. You can also use the Import feature to import archive files containing Java portlets into your WorkSpace Studio workspace. For details, see Importing and Exporting Java Portlets.

Customizing Java Portlets Using weblogic-portlet.xml

WebLogic Portal allows you to add more functionality to java portlets than you can obtain using the standard JSR 168 specification. You can use the optional weblogic-portlet.xml file to inject some additional features. The following sections provide some examples.

Floatable Java Portlets

If you want to create a floatable Java portlet, you can do so by declaring a custom state in weblogic-portlet.xml as shown in the following example code:

    <portlet>

<portlet-name>fooPortlet</portlet-name>

<supports>

<mime-type>text/html</mime-type>

<window-state>

<name>float</name>

</window-state>

</supports>

    </portlet>

Adding an Icon to a Java Portlet

To add an icon to a Java portlet, you need to edit the weblogic-portlet.xml file, as described in this section.

  1. Place the icon in the images directory of the skin that the portal is using. For example, if the skin name is avitek, icons must be placed in:
  2. myPortal/skins/avitek/images

  3. In the Application panel, locate and double-click the weblogic-portlet.xml file to open it. This file is located in the portal's WEB-INF folder, for example:
  4. myPortal/WEB-INF/weblogic-portlet.xml

  5. Add the following lines to the weblogic-portlet.xml file:
  6. <portlet>
    <portlet-name>myPortlet</portlet-name>
    <supports>
    <mime-type>text/html</mime-type>
    <titlebar-presentation>
    <icon-url>myIcon.gif</icon-url>
    </titlebar-presentation>
    </supports>
    </portlet>
  7. Make these substitutions:
    • Change myPortlet to the name of the portlet that is specified in WEB-INF/portlet.xml
    • Be sure the mime-type also matches the mime-type found in WEB-INF/portlet.xml
    • Change myIcon.gif to the name of the icon you wish to add

Portlet Init-Params

The init-param element contains a name/value pair as an initialization parameter of the portlet. You can use the getInitParameterNames and getInitParameter methods of the javax.portlet.PortletConfig interface to return these initialization parameter names and values in your portlet code. Init-params are described in the JSR168 specification.

You can add init-params to your Java portlet by dragging a New Init-Param icon from the Design Palette onto the Java portlet in the portlet editor. Then, click on the init-param section of the portlet to display the parameter’s properties in the Property view. In the Property view, you can enter the following init-param data:

For example, if you created an init-param called “Color” and set the default value to “green,” the following entry will be made in the portlet.xml file:

<init-param>
    <description>My init param</description>
    <name>Color</name>
    <value>green</value>
</init-param>

Java Page Flow Portlets

You can use the Portlet Wizard to built a portlet that uses Apache Beehive Page Flows to retrieve its content.

To create a page flow portlet, follow these steps:

  1. Right-click the folder where you want to store the page flow portlet. (The folder must be within the WebContent directory.)
  2. Select New > Portlet.
  3. The New Portlet dialog displays.

  4. Enter a name for the portlet and click Create.
  5. The Portlet Wizard displays the Select Portlet Type dialog.

  6. Select the Java Page Flow Portlet radio button and click Next.
  7. The Portlet Wizard displays the Portlet Details dialog; Figure 5-12 shows an example.

    Figure 5-12 Portlet Wizard - JPF Portlet Details Dialog


    Portlet Wizard - JPF Portlet Details Dialog

  8. Specify the values you want for this portlet, following the guidelines shown in Table 5-3.
  9. Table 5-3 Portlet Wizard - JPF Portlet Data Entry Fields  
    Field
    Description
    Title
    The title for this portlet, which displays in the title bar if you select to include one.
    Content Path
    The Page Flow Request URI. You can type a value here, or click the Browse button Edit Title(s) Dialog to open a class picker and select the appropriate class.
    If you use the class picker to choose a page flow class, this fully-qualified class name is converted to a URI path of a JPF. The JPF does not reside in the project, but is referred to by the .portlet file when the portlet is created.
    If you enter or navigate to a .java that has no corresponding class in the project or J2EE Shared Libraries, the Portlet Wizard creates the .java file for the page flow. If multiple project source directories exist, then the wizard prompts you to store the new .java file in the source directory of your choice.
    Error Page Path
    To designate a default error page to appear in case of an error, check the box and indicate the path to the desired URI.
    Has Titlebar
    If you want your portlet to have a title bar, check this box. The displayed title matches the value in the Title field. In order for a portlet to have changeable states or modes, the portlet must have a title bar.
    State
    Select the desired check boxes to allow the user to minimize, maximize, float, or delete the portlet. For a more detailed description of portlet states, refer to Portlet States.
    Available Modes
    You can enable access to Help from the portlet or you can allow the user to edit the portlet.
    To enable an option, select the desired check box and provide the path to the JSP page or page flow that will provide the appropriate function. For a more detailed description of portlet modes, refer to Portlet Modes.

  10. Click Create.
  11. The WorkSpace Studio window updates, adding the Portlet_Name.portlet file to the display tree; by default, WorkSpace Studio places the portlet file in the same directory as the content file.

In order to fully understand the process of creating a page flow portlet, you should be familiar with the concept of Page Flows. For more information on using page flows with WebLogic Portal, refer to the Portal Development Guide.

If you want to create a page flow portlet that calls a web service, refer to Web Service Portlets.

JSF Portlets

You can create JSF portlets for a WSRP producer or a framework web application that has the JSF facet installed (that is, you selected the JSF facet when you created the portal web project).

Note: The Java Server Faces (JSF) Portlet selection only appears in the Portlet Wizard if you have added the JSF Project Facet to you portal web project. To add the JSF Project Facet, right-click the portal web project in the Package Explorer. In the Properties dialog, select Project Facets in the tree on the left. Click Add/Remove Project Facets, select JSF in the Project Facets dialog, and click Finish.

To create a JSF portlet, follow these steps:

  1. Right-click in the Package Explorer view, within the web content directory, and select New > Portlet from the menu.
  2. The New Portlet dialog displays. Figure 5-15 shows an example of the New Portlet dialog.

    Figure 5-13 Portlet Wizard - New Portlet Dialog


    Portlet Wizard - New Portlet Dialog

    The parent folder defaults to the location from which you selected to add the portlet.

  3. Edit the parent folder field if needed to indicate the project and directory for the new portlet.
  4. The Finish button is initially disabled; the button enables when you select a valid parent folder and 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.

  5. Type a file name for the new portlet.
  6. Click Finish to continue.
  7. The Portlet Wizard displays the Select Portlet Type dialog.

  8. Click Java Server Faces (JSF) Portlet and then click Next.
  9. The Portlet Wizard displays the Portlet Details dialog; Figure 5-14 shows an example.

    Figure 5-14 Portlet Wizard - JSF Portlet Details Dialog


    Portlet Wizard - JSF Portlet Details Dialog

  10. Specify the values you want for this portlet, following the guidelines shown in Table 5-4.
  11. Table 5-4 Portlet Wizard - JSF Portlet Data Entry Fields  
    Field
    Description
    Title
    The value for the portlet title, which displays in the title bar if enabled.
    Content Path
    The value for the Content URI; this value should point to a JSF-enabled .jsp file.
    Error Page Path

    Note: Error pages are not supported with JSF portlets.

    Has Titlebar
    If you want your portlet to have a title bar, check this box. The displayed title matches the value in the Title field. In order for a portlet to have changeable states or modes, the portlet must have a title bar.
    State
    Select the desired check boxes to allow the user to minimize, maximize, float, or delete the portlet. For a more detailed description of portlet states, refer to Portlet States.
    Available Modes
    You can enable access to Help from the portlet or you can allow the user to edit the portlet.
    To enable an option, select the desired check box and provide the path to the file that will provide the appropriate function. For a more detailed description of portlet modes, refer to Portlet Modes.

  12. Click Create.
  13. The WorkSpace Studio window updates, adding the Portlet_Name.portlet file to the display tree.

Placing Multiple JSF Portlets on a Portal Page

If you want to have more than one JSF portlet on a portal page, use the namingContainer JSP tag immediately after a JSF view tag, in order to provide component naming in the generated component tree. See Supporting Unique JSF Component Identifiers for an example.

Using JSPs in JSF Portlets

If you are using JSPs in your JSF portlets, be aware that you will only see your JSP edits when you view the portlet in a new session. A simple page refresh is not sufficient. This behavior differs from typical JSP development behavior, where changes are compiled and made available after a page refresh. Normally, JSPs are handled by the servlet container, which checks for updated JSPs. JSF, on the other hand, uses JSPs as a source for the component tree, which typically is loaded only once per session, depending on how the JSF implementation handles or does not handle changed JSP source. To see your JSP changes reflected in a JSF portlet, you must view the portlet in a new session. Typically, you can do this by opening a new browser to view the portal.

Supporting Unique JSF Component Identifiers

JSF applications associate a unique identifier with each JSF component in the component tree. When multiple JSF applications appear on a portal page, it becomes necessary to further scope these unique identifiers.

WLP provides the following features to support scoping JSF component identifiers on a portal page:

These features are discussed in the WLP Javadoc for the com.bea.portlet.adapter.faces package.

Listing 5-2 is an example that demonstrates how to use the <namingContainer> tag. The <namingContainer> tag is described in detail in the JSP Tag Javadoc.

Listing 5-2 Using the <namingContainer> Tag
<%@ page language='java' contentType='text/html;charset=UTF-8'%>
<%@ taglib uri='http://java.sun.com/jsf/core' prefix='f' %>
<%@ taglib uri='http://bea.com/faces/adapter/tags-naming' prefix='jsf-naming' %>
<%@ taglib uri='http://java.sun.com/jsf/html' prefix='h' %>
<f:view>
<jsf-naming:namingContainer id='myPortlet'>
<h:outputText value='Hello World'/> </jsf-naming:namingContainer>
</f:view>

Browser Portlets

Browser portlets, also called Content URI 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 from the portal project.

Tip: A clipper portlet also lets you include remote web content in a portal page. For information on clipper portlets and how they differ from browser portlets, see Creating Clipper Portlets.

There are several ways to invoke the Portlet Wizard, as explained in the section Starting the Portlet Wizard. This description assumes that you right-click in the Package Explorer view tree within a portal project and select New > Portlet from the menu.

To create a browser portlet, follow these steps:

  1. Right-click in the Navigation tree within a portal project and select New > Portlet from the menu.
  2. The New Portlet dialog displays. Figure 5-15 shows an example of the New Portlet dialog.

    Figure 5-15 Portlet Wizard - New Portlet Dialog


    Portlet Wizard - New Portlet Dialog

    The parent folder defaults to the location from which you selected to add the portlet.

  3. Edit the parent folder field if needed to indicate the project and directory for the new portlet.
  4. The Finish button is initially disabled; the button enables when you select a valid parent folder and 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.

  5. Type a file name for the new portlet.
  6. Click Finish to continue.
  7. The Portlet Wizard displays the Select Portlet Type dialog.

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

    Figure 5-16 Portlet Wizard - Browser Portlet Details Dialog


    Portlet Wizard - Browser Portlet Details Dialog

  10. Specify the values you want for this portlet, following the guidelines shown in Table 5-5.
  11. Table 5-5 Portlet Wizard - Browser Portlet Data Entry Fields  
    Field
    Description
    Title
    The title for the portlet. This value appears in the title bar of the portlet in the editor view of the WorkSpace Studio workbench.
    Content URL
    The value for the Content URL (external URL) that the portlet should use to retrieve its information.
    A validator checks the format of the URL that you enter, and a message notifies you if the URL is not properly formatted. You can either change the URL or ignore the warning and continue with the URL as is.
    Has Titlebar
    If you want your portlet to have a title bar, check this box. The displayed title matches the value in the Title field. In order for a portlet to have changeable states or modes, the portlet must have a title bar.
    State
    Select the desired check boxes to allow the user to minimize, maximize, float, or delete the portlet. For a more detailed description of portlet states, refer to Portlet States.
    Available Modes
    You can enable access to Help from the portlet or you can allow the user to edit the portlet.
    To enable an option, select the desired check box and provide the path to the JSP page that will provide the appropriate function. For a more detailed description of portlet modes, refer to Portlet Modes.

  12. Click Create.
  13. The WorkSpace Studio window updates, adding the Portlet_Name.portlet file to the display tree; by default, WorkSpace Studio places the portlet file in the same directory as the content file.

Note: The internal implementation of Browser portlets depends on asynchronous portlet content rendering; because of this, the portlet attribute Async Content displayed in the Properties view is set to none and is read-only. For more information about asynchronous content rendering, refer to Asynchronous Portlet Content Rendering.

Clipper Portlets

A clipper portlet is a portlet that renders content from another web site. A clipper portlet can include all or a subset of another web site’s content using a process called “web clipping.” Clipper portlets are discussed in Creating Clipper Portlets.

Struts Portlets

Use the Portlet Wizard to generate a portlet based on a Struts module, as explained in this section.

Before you can create a Struts portlet, you must first integrate your existing Struts application into your portal web application. For detailed information on integrating Struts applications into WebLogic Portal, refer to the Portal Development Guide.

Tip: It is highly recommended that you fully develop and test a Struts application before attempting to host it within a portal. This helps to separate the complexities of developing a working Struts application from the additional issues involved in putting the Struts application into a portlet.

To create a Struts portlet, follow these steps:

  1. Right-click the Struts application module’s XML configuration file located in the WEB-INF directory of the portal web application.
  2. Select Generate Portlet from the menu. The wizard automatically collects and displays the module path and configuration file name(s) in the Struts Config File dialog. An example is shown in Figure 5-17. Use the Browse and Add buttons to locate and add additional configuration files, if applicable.
  3. Figure 5-17 Struts Config File Dialog


    Struts Config File Dialog

  4. Click Next.
  5. In the Struts Actions dialog, specify an action for the Struts portlet. The actions that appear in the drop-down menu are based on entries in the configuration file(s) that were added previously.
  6. Figure 5-18 Struts Actions Dialog


    Struts Actions Dialog

  7. Click Create.

The WorkSpace Studio window updates, adding the Portlet_Name.portlet file to the display tree; by default, WorkSpace Studio places the portlet file in the directory that you specified in the Struts Module Path dialog of the wizard.

Remote Portlets

Because remote portlet development is a fundamental task in a federated portlet environment, the task of creating remote portlets is described in detail within the BEA WebLogic Portal Federated Portals Guide.

The following types of portlets can be exposed with WSRP inside a WebLogic portal:

Web Service Portlets

A web service portlet is a special type of page flow portlet, allowing you to call a web service. You create web service portlets using the features of WorkSpace Studio and WebLogic Portal.

Before you can create a portlet that calls a web service, you must perform the following prerequisite tasks:

  1. Create a Java control from a web service.
  2. Call the Java control from a page flow.

Instructions on performing these tasks are contained in the WorkSpace Studio.

After you have performed the setup tasks, you can create a web service portlet by following these steps:

  1. In WorkSpace Studio, navigate to the page flow that you want to use as the basis for the portlet.
  2. Follow the instructions for creating a Java Page Flow portlet, as described in Java Page Flow Portlets.

 


Detached Portlets

WebLogic Portal supports the use of detached portlets, which provide popup-style behavior. Technically, a detached portlet is defined as anything outside of the calling portal context. Any portlet type supported by WebLogic Portal can be rendered as a detached portlet.

Considerations for Using Detached Portlets

Keep the following considerations in mind as you implement detached portlets:

Building Detached Portlets

You use the standalonePortletUrl class or associated JSP tag to create URLs to detached portlets.

To create a detached portlet URL from a JSP page, you use the render:standalonePortletUrl JSP tag or class; the following example shows the syntax of the JSP tag:

<render:standalonePortletUrl portletUri="/absolute_path/detached_portlet_name.portlet" …/>

To create a detached portlet URL from Java code, use the following example as a guide:

StandalonePortletURL detachedURL = StandalonePortletURL.createStandalonePortletURL(request, response);
detachedURL.setPortletUri(“/path/to/detached.portlet”);

 


Working with Inlined Portlets

A file-based portlet can exist either as a stand-alone .portlet file or as an inlined portlet. Typically, within the WorkSpace Studio portal editing framework, .portlet files are included in portals by reference. For instance, when you drag a .portlet file onto a portal, page or book, a reference is created to the portlet file inside the portal, page, or book. On the other hand, an inlined portlet’s entire XML definition is embedded directly in a page or book.

Inlined portlets are created under the following circumstances:

You can drag and drop, cut, copy, and paste inline portlets from one page or book to another from within the portal editor.

Figure 5-19 shows a remote page that contains an inlined portlet and a referenced portlet. Note that the icon used in an inlined portlet is distinct from a referenced portlet.

Figure 5-19 Inlined Portlet in the Portlet Editor

Inlined Portlet in the Portlet Editor

Tip: You can edit the properties of inlined portlets exactly like file-based portlets; however, portlet states and modes are not editable for inlined portlets.

Extracting Inlined Portlets

You can export an inlined portlet to a .portlet file. When you do this, the resulting .portlet file is functionally equivalent to any other .portlet file. When you extract an inlined portlet, the inlined portlet XML code is automatically removed from the source file (a page or book) and replaced with a reference to the newly created .portlet file.

Note: After you extract an inlined portlet, you can undo the operation (re-inline the portlet). However, note that the .portlet file that was created during the extraction will not be deleted from your system. The source document will simply not reference the .portlet file any longer.

To extract an inlined portlet, do the following:

  1. Right-click the inlined portlet in the Book or Page Editor and select Extract Portlet to New File, as shown in Figure 5-20.
  2. Figure 5-20 Extract Portlet to New File


    Extract Portlet to New File

  3. In the Save As dialog, enter a name for the new portlet.
Tip: If you receive errors after extracting a portlet, be sure to save the source file and run the Project > Clean command.

Setting the Theme of an Inlined Portlet

You can set the theme of an inlined portlet exactly as you would for a referenced portlet. To set the theme, right-click the inlined portlet in the book or page editor, and pick a theme from the Theme menu. The theme is retained for that portlet as long as it remains referenced in the page or book.

 


Extracting Books and Pages

You can extract any book or page in a portal to a .book or .page file. Once a book or page is extracted, you are free to use it in another portal within the same portal web application if you wish.

The procedure for extracting books and pages is similar to the procedure for extracting inlined portlets, described in Extracting Inlined Portlets. To extract a book or page, do the following:

  1. Right-click border of the book or page in the Portal Editor and select Extract Book (or Page) to New File.
  2. In the Save As dialog, enter a name for the new book or page file.
Tip: Any theme applied to a book or page is retained for an extracted book or page as long as the book or page remains referenced in the portal.

 


Portlet Properties

Portlet properties are named attributes of the portlet that uniquely identify it and define its characteristics. Some properties—such as title, definition label, and content URI—are required; many optional properties allow you to enable specific functions for the portlet such as scrolling, presentation properties, pre-processing (such as for authorization) and multi-threaded rendering. The specific properties that you use for a portlet vary depending on your expected use for that portlet.

During the development phase of the portal life cycle, you generally edit portlet properties using the WorkSpace Studio interface; this section describes properties that you can edit using WorkSpace Studio.

During staging and production phases, you typically use the WebLogic Portal Administration Console to edit portlet properties; only a subset of properties are editable at that point. For instructions on editing portlet properties from the WebLogic Portal Administration Console, refer to Modifying Library Portlet Properties and Modifying Desktop Portlet Properties.

For a detailed description of all portlet properties, refer to Portlet Properties in the Portal Properties View and Portlet Properties in the Portlet Properties View.

This section contains the following topics:

Editing Portlet Properties

To edit portlet properties, follow these steps:

  1. Navigate to the location of the portlet whose properties you want to edit, and double-click the .portlet file to open it in the workbench editor.
  2. Click the border of the desired portlet component to display the properties for that component in the Properties view.
  3. The displayed properties vary according to the active area that you select. If you click the outer border, properties for the entire portlet appear; if you click the inner border, properties for the content of the portlet appear, and so on.

  4. Navigate to the Properties view to view the current values for the portlet properties. Figure 5-21 shows a segment of a JSP portlet’s Properties view:
  5. Figure 5-21 Editing Portlet Properties - JSP Portlet Properties View Example


    Editing Portlet Properties - JSP Portlet Properties View Example

  6. Double-click the field that you want to change.
  7. If you click on a property field, a description of that field displays in the status bar.

    Values for some portlet properties are not editable after you create the portlet.

    In some cases, from the property field you can view associated information pertaining to that portlet property; for example, the Java portlet Class Name property contains a read-only value with an Open button to view the associated Java file. For more information about options available in the Properties view, refer to Tips for Using the Properties View.

Tips for Using the Properties View

The behavior of the Properties view varies depending on the type of field you are editing. The following tips might help you as you manipulate the content of the data fields in the Properties view.

Portlet Properties in the Portal Properties View

The properties described in this section are contained within the .portal file and are editable using the WorkSpace Studio workbench. The values you enter here override the corresponding value in the .portal file, if a value exists there.

To display the portlet properties that display in the Properties view for a portal, follow these steps:

Note: These steps assume that you have an existing portal that contains portlets.
  1. Double-click the .portal file of the portal for which you want to view portlet instance properties.
  2. A WYSIWYG view of the portal appears in the editor.

  3. Click a portlet to highlight it.
  4. An orange border appears around the outside edge of the portlet.

The Properties view displays the properties of the portlet instance; Figure 5-22 shows an example.

Figure 5-22 Portlet Instance Properties in the Portal Properties View

Portlet Instance Properties in the Portal Properties View

Table 5-6 describes these properties and their values.

Table 5-6 Portlet Instance Properties in the Properties View 
Property
Value
Default Minimized
Optional. Select true for the portlet to be minimized when it is rendered. The default value is false. Change the value for this property only if you want to override the default value provided by the .portlet file.
Instance Label
Required. A single portlet, represented by a .portlet file, can be used multiple times in a portal. Each use of that portlet is a portlet instance, and each portlet instance must have a unique ID, or Instance Label. A default value is entered automatically, but you can change the value. Instance labels help WebLogic Portal manage the runtime state of multiple instances of portlets independently of each other on the server. WebLogic Portal also uses instance labels during URL rewriting and scoping of various HTML controls such as names of forms, and ID attributes.
Orientation
Optional. Hint to the skeleton to position the portlet title bar on the top, bottom, left, or right side of the portlet. You must build your own skeleton to support this property. The allowable values are: default, top=0, left,=1 right=2, bottom=3.
Enter a value for this property only if you want to override the orientation specified in the .portlet file. Selecting default removes the orientation attribute from the portlet, book, and/or portlet instance; use this value if you want to revert to the framework default setting for this attribute.
Portlet URI
Required. The path (relative to the project) of the parent .portlet file. For example, if the file is stored in Project\myportlets\my.portlet, the Portlet URI is /myportlets/my.portlet.
Theme
Optional. Select a theme to give the portlet a different Look & Feel than the rest of the desktop.
Title
Enter a title if you want to override the default title specified in the .portlet file. The title is used in the portlet title bar.

Portlet Properties in the Portlet Properties View

The properties described in this section are contained within the .portlet file and are editable using the WorkSpace Studio workbench. The values you enter here override the corresponding value in the .portlet file, if a value exists there.

When you select the outer border of a portlet instance in the editor, a related set of properties appears in the Properties view. The displayed properties vary according to the type of portlet that you are viewing. Figure 5-1 shows a portion of the Properties view for a portlet.

Figure 5-1 Properties View Example Showing Portlet Properties

Properties View Example Showing Portlet Properties

Table 5-7 describes these properties and their values.

Table 5-7 Properties in the Portlet Properties View  
Property
Value
Backable Properties
Portlet Backing File
Optional. If you want to use a class for preprocessing (for example, authentication) prior to rendering the portlet, enter the fully qualified name of that class. That class should implement the interface com.bea.netuix.servlets.controls.content.backing.JspBacking or extend com.bea.netuix.servlets.controls.content.backing.AbstractJspBacking. From the data field you can choose to browse to a class or open the currently displayed class.
Content
Content Path
Required. The path (relative to the project) to the file/class to be used for the portlet's content. From the data field you can choose to browse to a file (or class for page flow portlets) or open the currently displayed file/class. For example, if the content is stored in Project/myportlets/my.jsp, the Content URI is /myportlets/my.jsp.
Error Page Path
Optional. The path (relative to the project) to the JSP or HTML file to be used for the portlet's error message if the main content cannot be rendered. For example, if the error page is stored in Project/myportlets/error.jsp, the Content URI is /myportlets/error.jsp.
General Portlet Properties
Async Content Rendering
Allows you to specify whether to use asynchronous content for a given portlet and the implementation to use. An editable dropdown menu provides the selections none, ajax, and iframe. Portlet files that do not contain the asyncContent attribute appear with the initial value none displayed.
For more information, refer to Asynchronous Portlet Content Rendering.
Tip: You can also enable asynchronous rendering for an entire portal desktop by setting a portal property in either WorkSpace Studio or the WebLogic Portal Administration Console. For more information on asynchronous desktop rendering, see the WebLogic Portal Development Guide.
Cache Expires (seconds)
Optional. When the Render Cacheable property is set to true, enter the number of seconds after which the portlet cache expires.
Cache Render Dependencies
This instance-scoped boolean property appears in the Properties view whenever a window portlet or proxy portlet is loaded, allowing render dependencies to be cached. See also Portlet Dependencies.
The value defaults to true if the attribute is not already included in the .portlet file. The value is read-only for proxy portlets and editable for all other portlet types. For proxy portlets, the value is initialized from th e producer whenever a proxy portlet is generated from the portlet wizard.
This property does not affect posts targeted to the portlet.
Client Classifications
Optional. Select the multichannel devices on which the portlet can be viewed. The list of displayed devices is obtained from the file Project_Path\WEB-INF\client-classifications.xml. You must create this file to map clients to classifications in your portal web project. For more information about this task, refer to the Portal Development Guide.
In the Manage Portlet Classifications dialog:
  1. Select whether you want to enable or disable classifications for the portlet.
  2. Move the client classifications you want to enable or disable from the Available Classifications to the Selected Classifications.
  3. Click OK.
When you disable classifications for a portlet, the portlet is automatically enabled for the classifications that you did not select for disabling.
Default Minimized
Required. Select true if you want the portlet to be minimized when it is rendered. The default value is false.
Definition Label
Required. Each portlet must have a unique value within the web project. For Java portlets, you type the desired value when creating the portlet; for the remaining portlet types, a value is generated automatically when you create the portlet. Definition labels can be used to navigate to portlets. Also, components must have Definition Labels for entitlements and delegated administration.
As a best practice, you should edit this value in WorkSpace Studio to create a meaningful value. This is especially true when offering portlets remotely, as it makes it easier to identify them from the producer list.

Note: When you create a portlet instance on a desktop using the WebLogic Portal Administration Console, the generated definition label is not editable.

Description
Optional. A short text description of the portlet. The description is displayed in the Administration Console and Visitor Tools areas, and is sent from a WSRP producer where applicable.
Event Handlers
Optional. Use this value to configure interportlet communication using portlet events. The default is No event handlers. To select or add an event handler, click Browse in the Properties view. You an also click the Event Handlers link in the portlet editor. Both of these methods bring up the Portlet Event Handlers dialog box.
Forkable
For details on this property, refer to Portlet Forking.
Fork Pre-Render
For details on this property, refer to Portlet Forking.
Fork Pre-RenderTimeout (seconds)
For details on this property, refer to Portlet Forking.
Fork Render
For details on this property, refer to Portlet Forking.
Fork Render Timeout (seconds)
For details on this property, refer to Portlet Forking.
Orientation
Optional. Hint to the skeleton to position the portlet title bar on the top, bottom, left, or right side of the portlet. You must build your own skeleton to support this property in the .portal file. Following are the numbers used in the .portal file for each orientation value: top=0, left=1, right=2, bottom=3.
You can override the orientation in each instance of the portlet (in the Properties view).
Packed
Optional. Rendering hint that can be used by the skeleton to render the portlet in either expanded or packed mode. You must build your own skeleton to support this property.
When packed=”false” (the default), the portlet takes up as much horizontal space as it can.
When packed=”true,” the portlet takes up as little horizontal space as possible.
From an HTML perspective, this property is most useful when the window is rendered using a table. When packed=”false,” the table's relative width would likely be set to “100%.” When packed=”true,” the table width would likely remain unset.
Render Cacheable
Optional. To enhance performance, set to true to cache the portlet. For example, portlets that call web services perform frequent, expensive processing. Caching web service portlets greatly enhances performance.
Do not set this to true if you are doing your own caching.
For more information, refer to Portlet Caching.
Required User Properties Mode
Optional. Possible values are none, all, or specified. If the value is specified, then you must enter a list of property names in the field Required User Properties Names field.
Required User Properties Names
Optional. Use this field if you entered a value of specified in the Required User Properties Mode field; enter a comma-delimited list of property names.
Title
Required. Enter the title for the portlet's title bar. You can override this title in each instance of the portlet (in the portal editor, as described in Portlet Properties in the Portal Properties View).
Page Flow Content
Listen To
(Deprecated) The comma-separated list of instance labels of the portlets whose actions should also be called in the selected page flow portlet. This functionality has been replaced with the more complete interportlet communication mechanism.
Page Flow Action
Optional. The initial action to be executed in a page flow. If not specified, the begin action is used.
Page Flow Refresh Action
Optional. The action to be executed in the page flow when the page is refreshed but the portlet is not targeted. This is equivalent to using portlet event handlers configured on the onRefresh portal event to invoke the page flow action.
Request Attribute Persistence
Optional. Possible values are none, session, and transient-session. This attribute controls attribute persistence for Page Flow, JSF, and Struts portlets. The default is session, where request attributes populated by an action are persisted into a collection class that is placed into a session attribute so that the portal framework can safely include the forwarded JSP on subsequent requests without re-running the action. Using the value session can cause session memory consumption and replication that would not otherwise occur in a standalone Page Flow, JSF, or Struts application. The value transient-session places a serializable wrapper class around a HashMap into the session. The value none performs no persistence operation.
JPF or Struts portlets that have the transient-session value applied generally have the same behavior as existing portlets; however, in failover cases, the persisted request attributes disappear on the failed-over-to server. In the failover case, you must write forward JSPs to handle this contingency gracefully by, at a minimum, not expecting any particular request attribute to be populated; ideally you should include the ability to either repopulate automatically or present the user with a link to re-run the last action to repopulate the request attributes. For non-failover cases, request attributes are persisted, providing a performance advantage for non-postback portlets identical to default session persistence portlets.
Portlets that have the none value applied will never have request attributes available on refresh requests; you must write forward JSPs to assume that they will not be available. You can use this option to completely remove the framework-induced session memory loading for persisted request attributes.
Java Server Faces (JSF) Content
Faces Events
(Optional) Lets you add name/action pairs to a JSF portlet. The name field is simply an alias. Event handlers (and the Event Handler dialog) can simply reference this name. The action is a reference to a JSF view ID, such as myfaces/foo.face. For more information on adding event handlers, see Portlet Events.
Request Attribute Persistence
Refer to the description in the Page Flow Content section.
Portlet Properties
 
Content Presentation Class
A CSS class that overrides any default CSS class used by the component’s skeleton.
For proper rendering, the class must exist in a cascading style sheet (CSS) file in the Look and Feel’s selected skin, and the skin’s skin.xml file must reference the CSS file.
Sample: If you enter “my-custom-class”, the rendered HTML from the default skeletons looks like this:
<div class="my-custom-class">
The properties you enter are added to the component's parent <div> tag. This property also applies to books and pages. For more information, refer to the Portal Development Guide.
Content Presentation Style
Optional. The primary uses are to allow content scrolling and content height-setting.
For scrolling, enter the following attributes:
  • overflow:auto – Enables vertical and horizontal scrolling
For setting height, enter the following attribute:
  • height:200px
where 200px is any valid HTML height setting.
You can also set other style properties for the content as you would using the Presentation Style property. The properties are applied to the component's content/child <div> tag.
Offer as Remote
Optional. Defines whether the portlet is accessible using the WSRP producer. The default is true, which allows the portlet to be accessed. For more information about entitling remote portlets, refer to the Federated Portals Guide.
JSP Content
Content Backing File
Optional. If you want to use a backing file for content prior to rendering the portlet, enter the fully qualified name of the appropriate class. That class should implement the interface com.bea.netuix.servlets.controls.content.backing.JspBacking or extend com.bea.netuix.servlets.controls.content.backing.AbstractJspBacking.
Thread Safe
Optional. Performance setting for books, pages, and portlets that use backing files.
When Thread Safe is set to true, an instance of a backing file is shared among all books, pages, or portlets that request the backing file. You must synchronize any instance variables that are not thread safe.
When Thread Safe is set to false, a new instance of a backing file is created each time the backing file is requested by a different book, page, or portlet.
Portlet Title Bar
Can Delete
Optional. If set to true the portlet can be deleted from a page.
Can Float
Optional. If set to true the portlet can be floated into a separate window. For instructions on creating a floatable Java portlet, which requires editing the weblogic-portlet.xml file, in Customizing Java Portlets Using weblogic-portlet.xml.
Can Maximize
Optional. If set to true the portlet can be maximized.
Can Minimize
Optional. If set to true the portlet can be minimized.
Edit Path
Optional. The path (relative to the project) to the portlet's edit page.
Help Path
Optional. The path (relative to the project) to the portlet's help file.
Icon Path
Optional. The path (relative to the project) to the graphic to be used in the portlet title bar. You must create a skeleton to support this property.
Mode Properties (available when you add a mode to a portlet)
Content Path
Required. The path (relative to the project) to the JSP, HTML, or .java file to be used for portlet's mode content, such as the edit page. For example, if the content is stored in Project/myportlets/editPortlet.jsp, the Content URI is /myportlets/editPortlet.jsp.
Although a Browse button appears for this property, if you want to point to a page flow you must manually enter the path to the .java.
Error Path
Optional. The path (relative to the project) to the JSP, HTML, or .java file to be used for the error message if the portlet's mode page cannot be rendered. For example, if the error page is stored in Project/myportlets/errorPortletEdit.jsp, the Content URI is /myportlets/errorPortletEdit.jsp.
Although a Browse button appears for this property, if you want to point to a page flow you must manually enter the path to the .java.
Portlet Backing File
Optional. If you want to use a class for preprocessing (for example, authentication) prior to rendering the portlet's mode page (such as the edit page), enter the fully qualified name of that class. That class should implement the interface com.bea.netuix.servlets.controls.content.backing.JspBacking or extend com.bea.netuix.servlets.controls.content.backing.AbstractJspBacking.
Visible
Optional. Makes the mode icon (such as the edit icon) in the title bar or menu invisible (false) or visible (true). Set Visible to false when, for example, you want to provide an edit URL in a desktop header.
Mode Toggle Button Properties
Name
Optional. Displayed when you select an individual mode. An optional name for the mode, such as Edit.
Presentation Properties
Presentation Class
This property is described in the Portal Development Guide.
Presentation ID
This property is described in the Portal Development Guide.
Presentation Style
This property is described in the Portal Development Guide.
Properties
Optional. A comma-delimited list of name-value pairs to associate with the object. This information can be used by skeletons to affect rendering.
Skeleton URI
This property is described in the Portal Development Guide.
Proxy Portlet Properties
Connection Establishment Timeout
Optional. The number of milliseconds after which this portlet will time out when establishing an initial connection with its producer.
Connection Timeout
Optional. The number of milliseconds after which this portlet will time out when communicating with its producer, after the physical connection has been established. If not specified here, the default value contained in the file WEB-INF/wsrp-producer-registry.xml is used.
Group ID
Optional. This value is assigned by the producer and is not editable. Portlets with the same Group ID from the same producer can share sessions. The Group ID value is meaningful only to the producer and not manipulated by WebLogic Portal.
Invoke Render Dependencies
This boolean property allows the consumer to obtain render dependencies from the producer during the pre-render life cycle of a proxy portlet.
When a portlet on a producer has a lafDependenciesUri value, the producer exposes the invokeRenderDependencies boolean in the portlet description. For more information on this attribute, refer to Portlet Dependencies.

Note: Provide an absolute path for the lafDependenciesUri attribute, rather than a relative path.

The value defaults to false if the attribute is not included in the .portlet file. The value is read-only, and is initialized from the producer whenever a proxy portlet is generated from the portlet wizard.
Portlet Handle
Required. The producer’s unique identifier for the portlet that this proxy references. The value is not editable.
Producer Handle
Required. The producer’s unique identifier.
Templates Stored in Session
Indicates whether the producer stores URL templates in the user's session on the producer side. This boolean is meaningful only when URL Template Processing boolean is set to true.
URL Template Processing
Indicates whether the producer uses URL templates to create URLs. If true, the consumer supplies URL templates. If false, the producer rewrites URLs using special rewrite tokens.
User Context Stored In Session
Required. The purpose of this value is to cut down on network traffic by sending the user's context (including the profile) only once per session. For WebLogic Portal producers it will always be true. For third party producers it can be true or false, depending on the response from GetServiceDescription. If it is false, the entire user context will be sent on every getMarkup and performBlockingInteraction request. If true it will be sent only once per producer session.
This boolean value defaults to false if the attribute is not included in the .portlet file.
The value is read-only, and is initialized from the producer whenever a proxy portlet is generated from the portlet wizard.
Struts Content
Listen To
(Deprecated) Allows this portlet to invoke an action when another portlet invokes the same action. This functionality has been replaced with the more complete interportlet communication mechanism. For more information on interportlet communication, refer to Local Interportlet Communication.
Request Attribute Persistence
Refer to the description in the Page Flow Content section.
Struts Action
The begin action that this struts portlet should invoke on the first request to the portlet.
Struts Module
The struts module that is associated with this struts portlet.
A “struts module” is a means of scoping a particular set of struts actions to a group called a module, which generally maps to a single subdirectory of web resources and a separate struts-config.xml file.
Struts Refresh Action

Optional. The action to be performed in the struts module when the page is refreshed but the portlet itself is not targeted.

Uri Content (Browser portlet properties)
Content Url

Required. The content control takes a URI that is expected to be a URL for a standalone application or web page, and embeds the URL as portlet content.

 


Portlet Preferences

Portlet preferences provide the primary means of associating application data with portlets. This feature is key to personalizing portlets based on their usage. This section describes portlet preferences in detail.

After you create a portlet, you can instantiate it several times. Because you can create several instances of a portlet, it is natural to expect each instance to behave differently yet use the same code and user interface. For instance, consider a typical portlet to display a Stock Portfolio. Given a list of stock symbols, this portlet retrieves quotes from a stock quote web service periodically, and displays the quotes in the portlet window. By letting each user change the list of stock symbols and a time interval to reload the quote data, you can let each user customize this portlet.

The portlet needs to be able to store the list of stock symbols and the retrieval interval persistently, and update these values whenever a user customizes these values. In particular, the following data must be persistently managed:

Technically, a portlet preference is a named piece of string data. For example, a Stock Portfolio portlet could have the following portlet preferences:

You can associate several such preferences with a portlet. WebLogic Portal provides the following means to manage portlet preferences:

This section contains the following topics:

Specifying Portlet Preferences

The steps to associate preferences with a portlet depend on the type of portlet you are building. If you are using the Java Portlet API, described in Getting and Setting Preferences for Java Portlets Using the Preferences API, the steps follow those specified in the Java Portlet Specification. For other kinds of portlets, such as those using Java Page Flows, Struts, or JSPs, you can use the WorkSpace Studio workbench to add preferences to a portlet.

You can also allow the administrator to create new preferences using the Administration Console. However, because the portlet developer is more likely to be aware of how portlet preferences are used by the portlet, it is generally better to create portlet preferences during the development phase.

Specifying Preferences for Java Portlets in the Deployment Descriptor

For portlets using Java Portlet API, you can specify preferences in the portlet deployment descriptor according to the specification. For all portlets in a web project, the deployment descriptor is portlet.xml, found in the WEB-INF directory of the web project. Listing 5-3 provides an example.

Listing 5-3 Specifying Portlet Preferences in portlet.xml with a Single Value
<portlet>
   <description>This portlet displays a stock portfolio.</description>
   <portlet-name>portfolioPortlet</portlet-name>
   <portlet-class>portlets.stock.PortfolioPortlet </portlet-class>
      <supports>
         <mime-type>text/html</mime-type>
         <portlet-mode>edit</portlet-mode>
      </supports>
      <portlet-info>
         <title>My Portfolio</title>
      </portlet-info>
      <portlet-preferences>
         <preference>
            <name>stockSymbols</name>
               <value>BEAS, MSFT</value>
         </preference>
         <preference>
            <name>refreshInterval</name>
            <value>600</value>
         </preference>
   </portlet-preferences>
</portlet>

This snippet deploys the portfolio portlet with two preferences: a preference with name stockSymbols and value BEAS, MSFT, and another preference refreshInterval with value 600.

Instead of specifying a single value for the stockSymbols preference, you can declare each symbol as a separate value as shown in Listing 5-4 below, with the value elements shown in bold.

Listing 5-4 Specifying Portlet Preferences with Values Specified Separately
<portlet>
   <description>
      This portlet displays a stock portfolio.
   </description>
   <portlet-name>portfolioPortlet</portlet-name>
   <portlet-class>portlets.stock.PortfolioPortlet </portlet-class>
   <supports>
      <mime-type>text/html</mime-type>
      <portlet-mode>edit</portlet-mode>
   </supports>
   <portlet-info>
      <title>My Portfolio</title>
   </portlet-info>
   <portlet-preferences>
      <preference>
         <name>stockSymbols</name>
         <value>BEAS</value>
         <value>MSFT</value>
         </preference>
      <preference>
         <name>refreshInterval</name>
         <value>600</value>
      </preference>
   /portlet-preferences>
</portlet>

If you prefer that portlets should not be allowed to programmatically update any given preference, you can mark the preference as read-only. Listing 5-5 shows an example of preventing a portlet from changing the refreshInterval.

Listing 5-5 Specifying a Read-Only Portlet Preference Value
<portlet>
   <description>
      This portlet displays a stock portfolio.
   </description>
   <portlet-name>portfolioPortlet
   <portlet-class>portlets.stock.PortfolioPortlet
   <supports>
      <mime-type>text/html</mime-type>
      <portlet-mode>edit</portlet-mode>
   </supports>
   <portlet-info>
      <title>My Portfolio</title>
   </portlet-info>
   <portlet-preferences>
      <preference>
         <name>stockSymbols</name>
         <value>BEAS</value>
         <value>MSFT</value>
      /preference>
      <preference>
         <name>refreshInterval</name>
         <value>600</value>
         <read-only>true</read-only>
      </preference>
   </portlet-preferences>
</portlet>

Note that by marking a preference read-only, you are preventing the portlet from changing the current value only at request time. Portal administrators can always change the value(s) of a preference using the Administration Console.

Specifying Preferences for Other Types of Portlets using WorkSpace Studio

If you are building other kinds of portlets (such as those using Java Page Flows, Struts, or simple JSPs), you can add preferences using WorkSpace Studio.

To add a preference, follow these steps:

  1. Click to select the portlet for which you want to add a preference.
  2. In the Outline view for the portlet, right-click Preferences and in the context menu click Add Preference. Figure 5-23 shows an example of the preferences context menu.
  3. Figure 5-23 Portlet Preferences Context Menu


    Portlet Preferences Context Menu

    A new preference is added to the tree hierarchy with the name New Preference Preference.

  4. Click the new item to display its properties in the Properties view.
  5. Edit the values in the Properties view. Figure 5-24 shows an example of the fields in the Properties view.
  6. Figure 5-24 Portlet Preferences Properties View


    Portlet Preferences Properties View

Table 5-8 describes the attributes for portlet preferences as shown in the Properties view.

Table 5-8 Portlet Preference Properties
Field
Value
Modifiable
Indicates whether the preference is read-only or can be modified by the user. The default is true.
Multi Valued
Indicates whether the preference can have multiple values. The default is true.
To specify multiple values for a preference, create multiple preferences with the same name.
Description
A brief description of the preference.
Name
Name of the preference.
Value
Each preference can have one or more values. Each value is of type java.lang.String.

Using the Preferences API to Access or Modify Preferences

At request time, portlet preferences for a given portlet are represented as instances of the javax.portlet.PortletPreferences interface. This interface is part of the Java Portlet API. This interface specifies methods to access and modify portlet preferences.

Getting Preferences Using the Preferences API

Table 5-9 describes methods that allow a portlet to access its preferences.

Table 5-9 Methods that Allow a Portlet to Access its Preference Values  
Method
Purpose
String getValue(String name, String default)
Use this method to get the first value of a preference.
String[] getValues(String name, String[] defaults) 
Use this method to get all the values of a preference.
boolean isReadOnly(String name)
Use this method to determine whether a given preference is read-only.
Enumeration getNames()
Use this method to get an enumeration of the names of all preferences.
Map getMap()
Use this method to get a map of preferences. The keys in this map are the names of all the preferences, and the values are the same as those returned by getValues(String name, String[] defaults)

Setting Preferences Using the Preferences API

Table 5-10 describes methods that allow a portlet to change preference values.

Table 5-10 Methods that Allow a Portlet to Change Preference Values  
Method
Purpose
void setValue(String name, String value)
Use this method to set the value of a preference
void setValues(String name, String[] values)
Use this method to set several values for a preference
void store()
Use this method to commit the changes made to preferences for a portlet.
void reset(String name)
Use this method to reset the value of a preference to its default, or remove the preference if there is no default

After modifying preferences by calling setValue(), setValues() and reset() methods, you must call store() explicitly to make the changes permanent; otherwise, changes will not be made permanent.

Getting and Setting Preferences for Java Portlets Using the Preferences API

For portlets written using the Java Portlet API, you can obtain an instance of javax.portlet.PortletPreferences object from the incoming portlet request – javax.portlet.RenderRequest within the processAction() method, or javax.portlet.ActionRequest within the render() method.

In Listing 5-6, the portlet displays a form to edit the current values of portlet preferences in a JSP page included from the doEdit() method of the portfolio portlet.

Listing 5-6 Portlet Displays a Form to Edit Preferences
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<%@ page import="javax.portlet.PortletPreferences" %>

<portlet:defineObjects/>

<%
   PortletPreferences prefs = renderRequest.getPreferences();
   String refreshInterval = prefs.getValue("refreshInterval", "600");
   String symbols = prefs.getValue("stockSymbols", "BEAS, MSFT");
%>

<form method="POST" action="">
   <table>
      <tr>
         <td>Symbols</td><td><input name="symbols"          value="<%=symbols>"/></td>
      </tr>
      <tr>
         <td>Refresh Interval</td><td><input name="refreshInterval"
         value="<%=refreshInterval>"/></td>
      </tr>
      <tr>
         <td></td>
         <td><input type="submit" value="Submit"/></td>
      </tr>
   </table>
</form>

The portlet updates the preferences in its processAction() method, as shown in Listing 5-7.

Listing 5-7 Portlet Updates the Preferences in the processAction() Method
public class PortfolioPortlet extends GenericPortlet 
{
   {
      public void doEdit(RenderRequest renderRequest, RenderResponse
      renderResponse)
      throws IOException, PortletException
      {
         ...
      }
      public void processAction(ActionRequest actionRequest, ActionResponse
      actionResponse)
      throws PortletException
      {
         String refreshInterval =
         actionRequest.getParameter(“refreshInterval”);
         String symbols = actionRequest.getParameter(“stockSymbols”);

         PortletPreferences prefs = actionRequest.getPreferences();
         prefs.setValue(“refreshInterval”, refreshInterval);
         prefs.setValue(“stockSymbols”, symbols);
         try
         {
            prefs.store();
         }
         catch(SecurityException se) {
         // Thrown when the user does not have enough privileges to store
         // preferences. Make sure that the user logged into the portal.
         ...
         }
      catch(catch(IOException ioe) {
      // There is an error storing preferences
      ...
      }
   }
}

During processAction(), this portlet uses the javax.portlet.ActionRequest object to obtain preferences.

Getting and Setting Portlet Preferences Using the API for Other Portlet Types

Portlet preferences can be accessed and updated from other kinds of portlets too. The main difference is in the way your portlets obtain an instance of the javax.portlet.PortletPreferences object.

Both these classes provide a method getPortletPreferences(HttpServletRequest req) that takes javax.servlet.HttpServletRequest as an argument and return an object of type javax.portlet.PortletPreferences.

JSP Tags for Getting Portlet Preferences

WebLogic Portal provides a JSP tag library for setting up portlet preferences. Table 5-11 describes the applicable JSP tags.

Table 5-11 JSP Tags for Getting Portlet Preferences
Method
Purpose
getPreference
Use this tag to get the value of a portlet preference.
getPreferences
Use this tag to get all the values of a portlet preference. This tag can also used to write multiple values to the output separated by a separator.
forEachPreference
Use this tag to iterate through all the preferences of a portlet. You can nest other tags (getPreference, getPreferences, ifModifiable and Else) inside this tag.
ifModifible
Use this tag to include the body of this tag if the given portlet preference is not read-only.
else
Use this tag in conjunction with the ifModifiable tag to include the body of this tag if the given portlet preference is read-only

For more information on the Java classes associated with these tags, refer to the Javadoc.

Portlet Preferences SPI

In WebLogic Portal, the framework includes a default implementation that manages portlet preferences in the built-in PF_PORTLET_PREFERENCE and PF_PORTLET_PREFERENCE_VALUE database tables. If desired, you can replace this implementation with your own.

You can use the Portlet Preferences SPI to allow portal applications to manage portlet preferences outside framework-managed database tables. For example, you can store preferences along with other application data in another back-end system or a different set of database tables.

When propagating a portal, the preferences SPI participates in the propagation process. When you exporting data for the propagation, the SPI is called to obtain the preferences, and when you are importing data, the SPI is called to store the preferences.

The following sections describe how to use the Portlet Preferences SPI.

Implement the SPI

You specify the SPI using the interface com.bea.portlet.prefs.IPreferenceAppStore. An implementation of this class must be deployed as a EJB jar file.

Listing 5-8 provides an example.

Listing 5-8 Implementing the SPI Using the Interface IPreferencesAppStore

public interface IPreferenceAppStore extends EJBObject
{
   /**
   * Returns preferences for a portlet entity with the given uniqueId.
   *
   * The returned java.util.Map contains
   * com.bea.netuix.application.prefs.Preference
   * objects keyed against their names.</p>
   *
   * @param uniqueId unique ID
   * @return preferences
   */
   public Map getPreferences(PortletPreferencesId uniqueId) throws
   RemoteException, PreferenceAppStoreException;

   /**
   * Writes the preferences to the underlying persistence.
   *
   * This method should be implemented to be atomic. That is, the
   * implemenation should guarantee that either all preference
   * values are persisted or none at all.
   *
   * The java.util.Map argument should contain
   * com.bea.netuix.application.prefs.Preference
   * objects keyed against their names.
   *
   * @param uniqueId unique ID
   * @param preferences preferences
   */
   public void storePreferences(PortletPreferencesId uniqueId,
   Map preferences) throws RemoteException, PreferenceAppStoreException;

   /**
   * Clear all preferences for the given unique ID from the
   * underlying persistence store.
   *
   * @param uniqueIds unique IDs
   */
   public void removePreferences(PortletPreferencesId[] uniqueIds) throws
   RemoteException, PreferenceAppStoreException;
}

Using the SPI

To cause the framework to use a new SPI in place of the default SPI, you must update the EJB named PreferencePersistenceManager in the ejb-jar.xml file within netuix.jar. The value BEA_netuix.DefaultStore must be changed to the name of the SPI EJB as specified in its deployment descriptor (ejb-jar.xml). The value com.bea.portlet.prefs.provider.DefaultStoreHome must be changed to the home interface of the SPI implementation.

Caution: To edit the ejb-jar.xml file you need to copy the J2EE library resources into your project. Keep in mind that with future updates to the WebLogic Portal product, you might have to perform manual steps in order to incorporate product changes that affect those resources.

The code segment in Listing 5-9 shows the default entries, which you must change to use the SPI.

Listing 5-9 Example Code Showing Default Entries that Must be Changed

<session>
   <ejb-name>PreferencePersistenceManager</ejb-name>
   <home>com.bea.portlet.prefs.PreferencePersistenceManagerHome</home>
   <remote>com.bea.portlet.prefs.PreferencePersistenceManager</remote>
   <ejb-class>com.bea.portlet.prefs.PreferencePersistenceManagerImpl
   </ejb-class>
   <session-type>Stateless</session-type>
   <transaction-type>Container</transaction-type>
   <env-entry>
      <env-entry-name>prefs-spi-jndi-name</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
      <env-entry-value>BEA_netuix.DefaultStore</env-entry-value>
   </env-entry>
   <env-entry>
      <env-entry-name>prefs-spi-home-class-name</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
      <env-entry-value>com.bea.portlet.prefs.provider.DefaultStoreHome
      </env-entry-value>
   </env-entry>
<!-- Snip -->
</session>

Best Practices in Using Portlet Preferences

Desktop Testing of Portlet Preferences

In order to view and test the preferences that you have created, you must use a desktop view from the WebLogic Portal Administration Console rather than WorkSpace Studio’s Open on Server view.

Portlets accessed from .portal files cannot store preferences. If you update a preference using a .portal file, your portlet encounters a java.lang.UnsupportedOperationException error.

Users Must be Authenticated

You must provide a means for users to log in before they can update preferences; users who are updating portlet preferences must first be authenticated. If an anonymous user attempts to update a portlet, a java.lang.SecurityException error occurs.

Note that portlets can always get portlet preferences whether or not the user is anonymous or whether the portlet is accessed via a .portal file.

Do Not Store Arbitrary Data as Preferences

It is tempting to store arbitrary application data as portlet preferences. For example, if you have a portlet that allows users to upload and store documents on the server, it might seem appropriate to store those documents as portlet preferences. This is not a good practice. The purpose of portlet preferences is to associate some properties for a portlet instance without having to be aware of any implementation-specific portlet instance IDs. These properties allow customization of the portlet’s behavior. The underlying implementation of portlet preferences is not designed for storing arbitrary application data.

The following steps outline an alternative implementation that can meet the needs of the portlet:

Perform setup steps:
  1. Add a preference to your portlet. This preference acts as the primary key to your portlet’s application data. Assign a default value for this preference.
  2. Create tables in your database to store application data with the value of the preference as the primary key.
Set up preferences in your portlet:
  1. When you want to associate application data with the current portlet instance, check the value of the preference. If the value is the default, generate a new value (for example, using a sequence number generator), and set this as the value of the preference, and store the preference.
  2. If the value of the preference is not the default, you do not need to generate a new value.
  3. Store your application data using the value of the preference as the primary key.

This procedure ensures that your application data is always scoped to portlet instances.

Do Not Use Instance IDs Instead of Preferences

The portal framework maintains instance identity using internally generated instance IDs. Portlets can access their instance IDs using getInstanceId() methods on com.bea.netuix.servlets.controls.portlet.PortletPresentationContext and com.bea.netuix.servlets.controls.portlet.PortletBackingContext.

Storing data directly in the database using portlet instance IDs does not work, for the following reasons:

 


Backing Files

The most common means of influencing portlet behavior within the control life cycle is to use a portlet backing file. A portlet backing file is a Java class that can contain methods corresponding to portal control life cycle stages, such as init() and preRender(). A portlet’s backing context, an abstraction of the portlet control itself, can be used to query and alter the portlet’s characteristics. For example, in the init() life cycle method, a request parameter might be evaluated, and depending on the parameter’s value, the portlet backing context can be used to specify whether the portlet is visible or hidden. For more information about backing contexts, refer to the Portal Development Guide.

Backing files can be attached to portals either by using WorkSpace Studio or coding them directly into a .portlet file.

Backing files are simple Java classes that implement the com.bea.netuix.servlets.controls.content.backing.JspBacking interface or extend the com.bea.netuix.servlets.controls.content.backing.AbstractJspBacking interface abstract class. The methods on the interface mimic the controls life cycle methods (refer to How Backing Files are Executed) and are invoked at the same time the controls life cycle methods are invoked.

The following portal controls support backing files:

The interportlet communication example in Local Interportlet Communication uses backing files.

This section contains the following topics:

How Backing Files are Executed

All backing files are executed before and after the JSP is called. In its life cycle, each backing file calls these methods:

Figure 5-25 illustrates the life cycle of a backing file.

Figure 5-25 Backing File Life Cycle

Backing File Life Cycle

On every request, the following sequence occurs:

Note: In the following steps, the methods are called unless items on inactive pages have been “optimized away” if tree optimization is enabled. For example, if tree optimization is enabled and items on an inactive page are not included on the resulting partial control tree, then the method is not called.
  1. All init() methods are called on all backing files in depth-first order (that is, in the order they appear in the tree). This method is called whether or not the control (the portal, page, book, or desktop) is on an active page.
  2. If the _nfpb parameter is set to true, all handlePostbackData() methods are called.
    • If the _nfpb parameter is set to true in the request parameter of any called handlePostbackData() methods, raiseChangeEvents() is called. This method causes events to fire, which is necessary if the backing file tries to make any state or mode changes.
Tip: You can use the method AbstractJspBacking.isRequestTargeted(request) to determine if a request is for a particular portlet.
  1. All preRender() methods are called for all portal framework controls on an active (visible) page.
  2. The JSPs are called and rendered on the active page.
  3. The dispose() method is called on each backing file.

Thread Safety and Backing Files

A new instance of a backing file is created per request, so you do not have to worry about thread safety issues. New Java VMs are specially tuned for short-lived objects, so this is not the performance issue it was in the past. Also, JspContent controls support a special type of backing file that allows you to specify whether or not the backing file is thread safe. If this value is set to true, only one instance of the backing file is created and shared across all requests.

Scoping and Backing Files

The difference between having a backing file as part of <netuix: portlet backingfile =some_value> or part of <netuix: jspContent backingfile=some_value> is related to scoping.

For example, if you have the backing file on the portlet itself, you can actually stop the portlet from rendering. If the backing file is at the jspContent level, the portlet portion of the control tree has already run; you use this implementation to run processes that are specifically for the JSP in the portlet.

Backing File Guidelines

Follow these guidelines when creating a backing file:

Listing 5-10 shows an example backing file.In this example, the AbstractJspBacking class is extended to provide the backing functionality required by the portlet. The example uses a session attribute because of the volatility of the HTTPRequest object; BEA recommends that you pass data between life cycle methods using the session rather than the request object.

Listing 5-10 Backing File Example
package backing;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.bea.netuix.events.Event;
import com.bea.netuix.events.CustomEvent;
import com.bea.netuix.servlets.controls.content.backing.AbstractJspBacking;
public class ListenCustomerName extends AbstractJspBacking
{
   public void listenCustomerName(HttpServletRequest request,
   HttpServletResponse response, Event event)
   {
      CustomEvent customEvent = (CustomEvent) event;
      String message = (String) customEvent.getPayload();
      HttpSession mySession = request.getSession();
      mySession.setAttribute("customerName", message);
   }
}

Adding a Backing File Using WorkSpace Studio

You can add a backing file to a portlet either from within WorkSpace Studio or by coding it directly into the file to which you are attaching it. Simply specify the backing file in the Backing File field of the Properties view, as shown in Figure 5-26. You need to specify the backing directory and, following a dot-separator, only the backing file name. Do not include the backing file extension; for example enter this:

backing.ListenCustomerName

Not this:

backing.ListenCustomerName.java

For the preceding example, if you include the file extension, the application interprets it as the file name—because the file path is specified by a dot-separator—and looks for a non-existent file called java in a non-existent directory called ListenCustomerName.

Figure 5-26 Adding a Backing File Using WorkSpace Studio

Adding a Backing File Using WorkSpace Studio

Adding the Backing File Directly to the .portlet File

To add the backing file by coding it into a .portlet file, use the backingFile parameter within the <netuix:jspContent> element, as shown in Listing 5-11.

Listing 5-11 Adding a Backing File to a .portlet File
<netuix:content>
<netuix:jspContent
backingFile="portletToPortlet.pageFlowSelectionDisplayOnly.menu.
backing.MenuBacking"
contentUri="/portletToPortlet/pageFlowSelectionDisplayOnly/menu/
menu.jsp"/>
</netuix:content>

 


Portlet Appearance and Features

Some aspects of portlet appearance are controlled by default at the portal level, such as colors, layouts, and themes. Appearance/rendering characteristics and portlet-specific features include the use of title bars and associated states (minimize, maximize, float, and delete) and modes that affect portlet content (edit mode, help mode, and custom modes).

The following sections describe how to work with portlet-specific appearance/content features and modes:

Portlet Dependencies

In a rendered HTML page, the proper place to include most types of resources, such as script files or style sheet references, is in the header of the document. Portlets sometimes need to specify resources that are required for rendering the portlet in the page. In the past, methods for making required elements available on the page included placing elements into the skeleton, which is not recommended because this creates a coupling between the skeleton and the portlet; or putting references directly in the portlet content, leading to the possibility of creating invalid HTML.

The problem was exacerbated in a federated (WSRP) environment because remote portlets are potentially included in several places and there was no way for one of these portlets to indicate that it relies on, for example, a piece of a CSS that resides in an external file.

WebLogic Portal now provides an explicit way to handle this requirement, using the portlet dependencies feature.

The concepts related to skin and skeleton resource dependencies are more formally known as render dependencies and script dependencies. Typical examples of such dependencies are CSS files and JavaScript files.

Both skins and skeletons can now specify such dependencies as well as associated search paths to be used for resolving these dependencies. Additionally, mechanisms exist to eliminate redundancy and to provide a reliable ordering for dependencies related to skins, skeletons, and theme skin and skeletons. These same capabilities are now available for portlets as well as portals, so that a portlet can specify necessary dependencies in a standards-compliant way; you identify these dependencies using appropriate elements located in the head section of the rendered page. The other advantages of the Look & Feel dependencies framework are also realized at a portlet level, such as reliable ordering and redundancy elimination.

This section contains the following topics:

Identifying Portlet Dependencies

The configuration of portlet dependencies shares the same mechanisms as the standard Look & Feel—you use an XML configuration document conforming to a standard Look & Feel schema. This XML document is referenced from a .portlet file using an attribute on the portlet element.

As with a Look & Feel’s render dependencies, you can resolve a portlet’s render dependencies utilizing a set of application search paths. Additionally, the search paths of the Look & Feel skin, or any appropriate Theme skin, are used before the portlet’s own search paths to resolve a portlet’s render dependencies.

You can specify a portlet’s dependencies configuration file in the WorkSpace Studio Properties view by entering the value in LAF Dependencies Path field. Alternatively, you can add the attribute lafDependenciesUri to the portlet element in a .portlet file, as shown in the following example:

<netuix:portlet definitionLabel="myPortlet" title="My Portlet" lafDependenciesUri="/portlets/example/myPortlet.dependencies">

By convention, you should adhere to the following guidelines when setting up a portlet’s dependencies configuration file:

Although the guidelines listed here are not required, deviating from them can lead to unexpected behavior. For more information, refer to Considerations and Limitations.

The portlet dependencies configuration file uses standard types from the standard Look & Feel schemas and looks similar to the example shown in Listing 5-12.

Listing 5-12 Portlet Dependencies Configuration File Example
<?xml version="1.0" encoding="UTF-8"?>
<p:window
xmlns:p="http://www.bea.com/servers/portal/framework/laf/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/servers/portal/framework/laf/1.0.0
laf-window-1_0_0.xsd ">
<p:render-dependencies>
<p:html>
<p:links>
<p:search-path>
<p:path-element>.</p:path-element>
</p:search-path>
<p:link rel="stylesheet" type="text/css" href="my.css"/>
</p:links>
</p:html>
</p:render-dependencies>
</p:window>

The configuration file shown in Listing 5-12 causes a CSS file to be included in the rendered page output (as a link element in the HTML head section). First, the search occurs for the CSS file relative to the Look & Feel or Theme skin search paths for the links element. If the CSS file is not found, then the search path in the configuration file is used. Relative search paths use the directory of the configuration file as a base.

The default behavior is to look first in the Look & Feel or Theme– specified search paths. This behavior allows a Look & Feel/Theme the ability to properly skin portlet resources. However, portlet-level resources should not be placed in the Look & Feel/Theme directories. If a situation arises when you do not want to use this behavior, you can disable it by specifying a value of false for the use-skin-paths attribute on the render-dependencies element.

Creating and Editing a Dependency File

You can use WorkSpace Studio to create a valid dependency file that you can then complete using Workshop’s XML editor.

Tip: For example dependency files, see Listing 5-12, Listing 5-13, and Listing 5-14.

The simplest way to create a dependency file is to select File > New > Other > Markup Files > Render Dependencies. The .dependencies file must reside in a WebLogic Portal framework project, within the web content folder (typically named WebContent).

You can also create a dependency file as follows:

  1. Select File > New > Other.
  2. In the New dialog, open the XML folder and select XML. The New XML File wizard opens.
  3. Choose Create XML From XML Schema File and click Next.
  4. Enter a name for the XML file in the XML File Name dialog and click Next.
  5. In the Select XML Schema File dialog, choose Select XML Catalog Entry and in the Key column select laf-window-1_0_0.xsd as the schema. Click Next.
  6. In the Select Root Element dialog, choose the root element window.
  7. Optionally check the boxes that add optional attributes/elements to your new XML file.
  8. Click Finish.
  9. Rename the generated file’s extension from .xml to .dependencies.

You can use the WorkSpace Studio XML editor to add elements and attributes to the dependency file. Right-click on an element and use the menu to select child elements and add attributes. As shown in Figure 5-27, valid choices based on the schema file are automatically populated in the menu.

Figure 5-27 Editing a Dependencies File

Editing a Dependencies File

Tip: The standard Eclipse hover-window help is available for XML schema elements in the Source view of the XML editor. Simply hover the mouse pointer over the element and a help pop-up appears. Also, in the Source view, you can click in an element and press F2 to display the help pop-up.

Example Dependency Files

This section includes the following examples:

Including JavaScript in a Render Dependencies File
Listing 5-13 illustrates how to include both an external JavaScript file as well as an embedded script. 
Listing 5-13 Including JavaScript
<p:window
xmlns:p='http://www.bea.com/servers/portal/framework/laf/1.0.0'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://www.bea.com/servers/portal/framework/laf/1.0.0
laf-window-1_0_0.xsd '>
<p:render-dependencies>
<p:html>
<p:scripts>
<p:search-path>
<p:path-element>.</p:path-element>
</p:search-path>
<p:script type='text/javascript' src='my.js'/>
<p:script type='text/javascript'>
alert('hello world');
</p:script>
</p:scripts>
</p:html>
</p:render-dependencies>
</p:window>
Including Meta and Style Elements in a Render Dependencies File

Listing 5-14 shows the use of both the metas and styles elements. The metas element lets you specify HTML meta tags, and the styles element lets you embed HTML style tags.

Listing 5-14 Use of Meta and Styling Elements
<p:window
xmlns:p='http://www.bea.com/servers/portal/framework/laf/1.0.0'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://www.bea.com/servers/portal/framework/laf/1.0.0
laf-window-1_0_0.xsd '>
<p:render-dependencies>
<p:html>
<p:metas>
<p:meta name='keywords' content='pirate, ninja'/>
</p:metas>
<p:styles>
<p:style type='text/css'>
div.myClass {
background-color: red;
}
</p:style>
</p:styles>
</p:html>
</p:render-dependencies>
</p:window>

Considerations and Limitations

At this time, WorkSpace Studio does not provide editing capabilities for portlet render dependencies configuration files; you can use the included Eclipse-based XML file editor for this purpose.

BEA recommends that you not share a single .dependencies file across several portlets. Although WebLogic Portal does not prevent this usage, sharing a single file might lead to confusion when coordinating updates to the file later.

Scoping JavaScript Variables and CSS Styles

Whenever you place multiple instances of a portlet on a page, you can encounter scoping problems with JavaScript variables and CSS styles. For example, if a portlet includes inlined JavaScript and you place two instances of that portlet on a page, it is possible that changing a JavaScript variable in one portlet will affect the other portlet.

To ensure that JavaScript and CSS styles are scoped to a specific portlet instance, add the token wlp_rewrite_ to the front of the variable or style class name. When the portlet is rendered, this token is replaced by the portlet instance label, which is unique for each portlet instance.

For example, to ensure portlet instance-level scoping of a JavaScript variable called stockQuote that is defined in a .js file that is referenced from a .dependencies file, you need to append wlp_rewrite_ to the front of the variable name:

var wlp_rewrite_stockQuote 

To ensure portlet instance-level scoping of a CSS class name called portlet_bg that is defined in a .css file that is referenced from a .dependencies file, you need to append wlp_rewrite_ to the front of the class name. For example:

.wlp_rewrite_portlet_bg { background_color:white; }

In both of these cases, the wlp_rewrite_ token is replaced by the portlet’s instance label, which is a unique identifier.

Note: The scoping mechanism described in this section only works for .css and .js files that are referenced with the content-uri dependency file attribute. Files linked with the src attribute or the link tag will not be rewritten.

Rewriting Resource URLs

WebLogic Portal also has the ability to rewrite URLs contained in the content of files referenced in a <script> or <style> section of a .dependencies file. The URLs are rewritten based on the standard Look and Feel URL Templating mechanism using the window-resource url-template-ref, as described in the section Optional Look And Feel URL Templates in the WebLogic Portal Development Guide.

For example, if your .dependencies file specifies:

 ...
      <p:styles>
        <p:search-path>
          <p:path-element>styles</p:path-element>
        </p:search-path>
        <p:style content-uri='my-style.css' type='text/css'/>
      </p:styles>
 ...

and the contents of my-style.css look like this:

.my_portlet_bg

{
    background-image: url('wlp_rewrite?/images/picture.gif/wlp_rewrite');
}

then when the portlet is rendered, the value of /images/picture.gif will be templatized based on the standard Look and Feel URL Templating mechanism.

In a non-WSRP case, this value can take one of two forms:

When the portlet that specifies the .dependencies file is being accessed remotely through a WLP remote (WSRP) portlet, then this rewritten URL also takes one of two forms:

Note: The rewriting mechanism described in this section only works for files that are referenced with the content-uri dependency file attribute. Files linked with the src attribute or the link tag will not be rewritten.

Portlet Modes

All portlets created with WebLogic Portal support the use of modes. Modes allow you to affect the end user’s ability to edit the portlet or display Help for the portlet. You add icon buttons to a portlet’s title bar to indicate the availability of a mode.

The following pre-defined modes exist for WebLogic Portal:

You can also create your own custom portlet modes using WebLogic Portal.

Buttons for the selected modes appear in the portlet’s title bar. Figure 5-28 shows an example of the default buttons for the portlet modes when displayed in the editor; Figure 5-29 shows the appearance of the mode icons in a running portlet.

Figure 5-28 Portlet Mode and State Buttons in Editor

Portlet Mode and State Buttons in Editor

Figure 5-29 Portlet Mode and State Buttons in a Running Portlet

Portlet Mode and State Buttons in a Running Portlet

When you use the Portlet Wizard to create a portlet, mode and state settings are available on the Portlet Details dialog. These settings can also be edited in the portlet’s Properties view: The following sections describe possible methods of performing these tasks.

Adding or Removing a Mode for an Existing Portlet

To add or remove the Help or Edit mode from the title bar, follow these steps:

  1. Display the portlet for which you want to add or remove a mode.
  2. Right-click the title bar of the displayed portlet to display the context menu. Figure 5-30 shows an example of the title bar context menu.
  3. Figure 5-30 Available Portlet Modes - Title Bar Context Menu


    Available Portlet Modes - Title Bar Context Menu

  4. Click Available Modes.
  5. Checkmarks on the submenu indicate the available modes for this portlet, which were determined when you created it. Figure 5-31 shows an example of the submenu.

    Figure 5-31 Portlet Mode - Available Modes Submenu


    Portlet Mode - Available Modes Submenu

  6. Click the mode for which you want to change the availability status. For example, in Figure 5-31, the Help mode is checked (available); when you click Help, the Help button Portlet Mode - Available Modes Submenu disappears from the title bar.
  7. Select File > Save to save your changes.

Properties Related to Portlet Modes

You can view and edit the mode's property details in the Properties view. For example, you can edit the Portlet Backing File property if you want to perform preprocessing before rendering the portlet's mode page (such as the edit page).

To display the mode properties for the portlet, click the expand/contract toggle button Portlet Mode - Available Modes Submenu in the Portlet Mode area of the portlet. Edit mode properties and Help mode properties display in the Properties view.

For descriptions of the mode properties, refer to Table 5-7.

Creating Custom Modes

A custom mode is a portlet mode that you implement. Like with the help and edit modes, a custom mode is activated with a button that appears in the portlet’s title bar. To implement a custom mode, you need to supply a display part, typically a JSP, and a backing file. This section includes an example that explains how to create a simple custom mode that lets a user add or remove the Maximize button from a portlet. Once you understand the basic principles involved in writing a custom mode, you can create a custom mode to perform the specific tasks you want.

Figure 5-32 shows the example portlet and the portlet’s custom mode view. When the user clicks the custom mode button in the example portlet on the left, the portlet display changes to the custom mode view on the right. In this example, the custom mode offers a way for the user to add or remove the portlet’s Maximize button.

Figure 5-32 Selecting a Custom Mode

Selecting a Custom Mode

  1. Create a JSP portlet in which to embed the custom mode. For information on JSP portlets, see JSP and HTML Portlets. For this example, any JSP portlet will suffice.
  2. Create a JSP page to display the custom mode view when a user clicks the custom mode button. For example, Listing 5-15 shows a JSP for a custom mode that lets a user add or remove the Maximize button from a portlet. The code to execute this action is in a backing file, which is discussed next. In this example, the JSP is called togglebutton.jsp.
  3. Listing 5-15 Sample Custom Mode JSP
    <%@ page import="com.bea.portlet.PostbackURL"%>
    <%
    PostbackURL url = PostbackURL.createPostbackURL(request, response);
    %>
    <TABLE CELLSPACING="10" ID="toggleButtonsTable">
    <TH>Using a Button and Backing File</TH>
    <TR>
    <TD>
    Click <b>Toggle</b> Off to remove the Maximize button from the portlet.<br>
    Click <b>Toggle On</b> to restore it.
    </TD>
    </TR>
    <TR>
    <TD>
    <FORM method="post" name="Toggle" action="<%=url.toString()%>">
    <INPUT ID="toggle_off" TYPE="SUBMIT" NAME="toggle_off" VALUE="Toggle            Off">
    <INPUT ID="do_nothing" TYPE="SUBMIT" NAME="do_nothing" VALUE="Toggle            On">
    </FORM>
    </TD>
    </TR>
    </TABLE>
  4. Create a backing file for the custom mode. Listing 5-16 implements the JspBacking interface and implements the preRender() method of that interface. In this example, the preRender() method removes the Maximize button from the portlet in response to a request. Refer to Javadoc for details on the API used in this example.
  5. Listing 5-16 Sample Backing File
    package modes;

    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import com.bea.netuix.servlets.controls.content.backing.JspBacking;
    import com.bea.netuix.servlets.controls.portlet.backing.PortletBackingContext;
    import com.bea.netuix.servlets.controls.window.WindowCapabilities;
    import com.bea.p13n.util.debug.Debug;

    public class MyMode implements JspBacking {

        public void dispose() {
        }

        public boolean handlePostbackData(HttpServletRequest arg0,
        HttpServletResponse arg1) {
            return true;
        }

        public void init(HttpServletRequest arg0, HttpServletResponse arg1) {
        }

        public boolean preRender(HttpServletRequest request, HttpServletResponse         response) {
            PortletBackingContext pbc =
            PortletBackingContext.getPortletBackingContext(request);
            if (request.getParameter("toggle_off") != null)
            {
                 try
                 {
                    pbc.setCapabilityVisible(WindowCapabilities.MAXIMIZED.getName(),
                    false);
                 }
                 catch (NullPointerException npe)
                 {
                      //
                 }
            }
            return true;
        }
    }
  6. Add a new custom mode to the portlet by dragging the New Custom Mode icon from the Design Palette to the portlet, as shown in Figure 5-33. You will be prompted to enter a name for the mode. You can enter a name now, or accept the default and change the name later.
  7. Figure 5-33 Adding a New Custom Mode


    Adding a New Custom Mode

  8. Open the Properties view for the custom mode. To do this, click in the Custom Mode region of the portlet in the portlet editor, as shown in Figure 5-34. The properties for the custom mode appear in the Properties view.
  9. Figure 5-34 Displaying Mode Properties


    Displaying Mode Properties

  10. In the Properties view, enter the path of the custom mode JSP in the Content Path field. This is the JSP that is displayed when the mode is activated. You can find the Content Path field in the Mode Properties section of the Properties view, as shown in Figure 5-35.
  11. In the Properties view, enter the name of the backing file class, including the full package name. You can find the Portlet Backing File field in the Mode Properties section of the Properties view, as shown in Figure 5-35.
  12. Figure 5-35 Specifying a Content File and a Backing File


    Specifying a Content File and a Backing File

    Tip: The Properties view lets you set many other custom mode properties, such as an image for the custom mode button, a rollover image, button text, alternate text, and others. Refer to Table 5-12 at the end of this section for information on each of the custom mode properties.
  13. Test the custom mode by placing the example portlet in a portal and running it on the server. Select the portlet’s custom mode button, as shown previously in Figure 5-32, to display the custom mode view. Click Toggle Off to remove the Maximize button, as shown in Figure 5-36.
  14. Figure 5-36 Testing the Example


    Testing the Example

Table 5-12 briefly describes each of the custom mode properties:

Table 5-12 Custom Mode Properties
Property
Value
Mode Properties
 
Content Path
Required. The path (relative to the project) to the file/class to be used for the custom mode portlet's content. From the data field you can choose to browse to a file (or class for page flow portlets) or open the currently displayed file/class. For example, if the content is stored in Project/myportlets/my.jsp, the Content URI is /myportlets/my.jsp.
Error Path
Optional. The path (relative to the project) to the JSP, HTML, or page flow file to be used for the error message if the portlet’s mode page cannot be rendered. For example, if the error page is in project/myportlets/errorPortletEdit.jsp, the Content URI is /myportlets/errorPortletEdit.jsp.
Portlet Backing File
Optional. If you want to use a class for preprocessing (for example, authentication) prior to rendering the portlet, enter the fully qualified name of that class. That class should implement the JspBacking interface or extend AbstractJspBacking. From the data field you can choose to browse to a class or open the currently displayed class.
Visible
Optional. Makes the mode icon in the title bar or menu invisible (false) or visible (true). Set Visible to false when, for example, you want to provide an custom mode URL in a desktop header.
Presentation Properties
 
Presentation Class
This property is described in the Portal Development Guide.
Presentation ID
This property is described in the Portal Development Guide.
Presentation Style
This property is described in the Portal Development Guide.
Properties
Optional. A comma-delimited list of name-value pairs to associate with the object. This information can be used by skeletons to affect rendering.
Skeleton URI
This property is described in the Portal Development Guide.
Toggle Button Properties
 
Activate Alternate Text
Popup text that appears when the mouse pointer hovers over the custom mode button.
Activate Image
An image for the button that activates the custom mode. Place the image in the images directory of the skin that your portal uses.
Activate Rollover Image URI
Provides a rollover image for the custom mode button. Place the image in the images directory of the skin that your portal uses.
Active
Not generally used, but available for use by custom skeletons.
Alternate Text
Not generally used, but available for use by custom skeletons.
Deactivate Alternate Text
Popup text that appears when the mouse pointer hovers over the custom mode button.
Deactivate Image URI
An image for the button that deactivates the custom mode. Place the image in the images directory of the skin that your portal uses.
Deactivate Rollover Image UI
Provides a rollover image for the button that deactivates the custom mode. Place the image in the images directory of the skin that your portal uses.
Image
Not generally used, but available for use by custom skeletons.
Name
The name of the custom mode. If specified, the name appears in the Portlet editor view, Outline view, and Properties view. If no name is supplied, a default name is used.
Rollover Image
Not generally used, but available for use by custom skeletons.

Portlet States

States determine the end user’s ability to affect the rendering of a portlet. WebLogic Portal supports these portlet states:

Normal – the typical rendered appearance of the portlet.

When you use the Portlet Wizard to create a portlet, state and mode settings are available on the Portlet Details dialog. These settings can also be edited in the portlet’s Properties view: The following sections describe possible methods of performing these tasks.

Modifying Portlet States in WorkSpace Studio

You can select which of the states you want to include with the portlet by following these steps:

  1. Right-click the portlet title bar.
  2. A context menu showing applicable states appears. Figure 5-37 shows an example of the title bar context menu showing all states as available.

    Figure 5-37 Portlet State - Title Bar Context Menu


    Portlet State - Title Bar Context Menu

  3. Click to select the state that you want to change.
  4. Selecting a state adds it to the portlet, while deselecting the state removes it from the portlet. For example, in Figure 5-37, all four states are selected, and appear in the title bar. If you click to deselect Deletable, the Delete button Portlet State - Title Bar Context Menu on the portlet disappears.

  5. Select File > Save to save your changes.

Minimizing or Maximizing a Portlet Programmatically

You can minimize or maximize a portlet either in the portlet file or in a portlet’s backing file. The actual code is the same for both. Here is an example of maximizing a (Java page flow) portlet:

PortletBackingContext context = PortletBackingContext.getPortletBackingContext(request);
context.setupStateChangeEvent(WindowCapabilities.MAXIMIZED.getName());

You can put this code in an action method of the Java page flow or in the handlePostbackData method of the backing file. When using the backing file, in order to get the handlePostbackData method to be called, you must have '_nfpb=true' in the URL.

These mechanisms do not work if asynchronous content rendering is enabled for the portlet.

Portlet Title Bar Icons

The default state and mode icons used in portlet title bars are stored in the wlp-lookandfeel-web-lib J2EE Shared Library; you can view them in Merged Projects view in the various subdirectories of framework/skins.

Portlet Height and Scrolling

All portlets created with WebLogic Portal support height and scrolling.

You can control the height of portlets and determine whether or not their contents scroll.

Portlet height and scrolling is controlled by the following CSS style attributes:

You can set these attributes on a portlet that is open in the workbench editor.

To set these properties, follow these steps:

  1. Open a portlet in the workbench editor.
  2. Click the outer border of the portlet to display the portlet properties in the Properties view.
  3. In the Properties view, set one of the following properties:
    • Presentation Style - Enter any of the previously listed attributes for this property. You can use overflow and height. Separate the values with a semicolon.
    • Presentation Class - Enter the name of a style sheet class that contains the height or scrolling attributes that you want to use.
    • Content Presentation Style - Enter any of the previously listed attributes for this property. You can use overflow and height. Separate the values with a semicolon.
    • Content Presentation Class - Enter the name of a style sheet class that contains the height or scrolling attributes that you want to use.
    • Note: The distinction between Presentation Style and Content Presentation Style, for example, is the location where the styling is applied (portlet or content). The use of one or the other depends on the specifics of what the specific styling is trying to accomplish.

      Figure 5-38 shows an example of a height property, set using Content Presentation Style.

      Figure 5-38 Portlet Height and Scrolling Presentation Properties Example


      Portlet Height and Scrolling Presentation Properties Example

      Based on the entries shown in Figure 5-38, the result looks similar to the example in Figure 5-39.

      Figure 5-39 Portlet Height and Scrolling—Portlet Appearance Results


      Portlet Height and Scrolling—Portlet Appearance Results

      If you use the Presentation Class property instead of the Presentation Style property, you must have the corresponding style class defined in a CSS file.

      For example, if you use the value .portlet-scroll in the Content Presentation Class field, you must have the following style class definition already set up in your CSS file:

      .portlet-scroll
      {
         overflow:auto;
         height:250px;
      }

  4. Select File > Save to save your changes.

Making All Portlets Scroll

To provide portlet height and scrolling automatically, you can specify an additional rule for the standard portlet content CSS class. For example, you can do one of the following:

For more information on portal skins, themes, and skeletons, refer to the Portal Development Guide.

 


Getting Request Data in Page Flow Portlets

A page flow stores information in the requests. If you have a portal page with multiple page flow portlets, you need a way for each page flow to individually store and retrieve that information. For example, the request object for a page might have a variable car_type, with a value of x. When the page flow runs, it obtains this value and uses it in some way. If you have another page flow portlet with a car_type value of z, and if only one request exists for the whole page, the two page flow portlets might interfere with each other. To prevent this problem, WebLogic Portal essentially makes a copy of the outer (portal) request to make separate scoped requests, one for each portlet. This gives each page flow portlet its own unique request to use to store its information.

In some cases, you might want to use information that is stored at the outer request rather than within the scoped request.

For example, if you use regular HTML tags within Netui form tags, you might have something similar to this:

<netui:form action="myAction">
   <input type="check box" name="test"/>
   <netui:button value="myAction"></netui:button>
</netui:form>

Based on the tags used above, you might typically use a regular getParameter request like this:

<%request.getParameter("test")%>

However, to get that HTML input value from the outer request, use the following:

<%@page import="org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils"%>
   <%
   HttpServletRequest outerRequest = ScopedServletUtils.getOuterRequest
   ( request );
   %>
   test: <%=outerReq.getParameter("test")%>

 


JSP Tags and Controls in Portlets

WebLogic Portal provides JSP tags that you can use within JSPs. You can view available JSP tags in the Design Palette and then drag them into the Source View of your JSP, and use the Properties view to edit elements of the code.

WebLogic Portal also provides custom Java controls that make it easy for you to quickly add pre-built modules to your portal; custom Java controls exist for event management, Visitor Tools, Community management, and so on. For example, most user management functionality can be easily exposed with a User Manager Control on a page flow.

Note: The term control is also used to refer to the portal (netuix) framework controls, such as desktop, book, page, and so on. These controls are referred to in the text as portal framework controls.

Viewing Available JSP Tags

When you open a JSP in WorkSpace Studio, you can use the Design Palette to display all the JSP tags currently loaded and available; Figure 5-40 shows a portion of the display.

Figure 5-40 Design Palette Showing Available JSP Tags

Design Palette Showing Available JSP Tags

To use a tag, drag it into the editor, use the Source View to edit the code directly, and use the Properties view to set properties, as shown in Figure 5-41:

Figure 5-41 Dragging a JSP Tag into the Design View – Properties for Add User JSP Tag

Dragging a JSP Tag into the Design View –  Properties for Add User JSP Tag

For information about the Java class associated with each JSP tag, refer to the Javadoc.

Viewing Available Controls

To view the available custom controls provided by WebLogic Portal when viewing a page flow:

  1. Open an existing page flow (.java file) or create a new page flow.
  2. For information about creating page flows using WorkSpace Studio, refer to the BEA Workshop User’s Guide.

  3. If you are not already using the Page Flow Perspective, WorkSpace Studio asks if you want to switch to it. Do so.
  4. Right-click in the source view for the Page Flow and select Insert > Control, as shown in Figure 5-1.
  5. Figure 5-1 Insert > Control Menu Selection


    Insert > Control Menu Selection

    The Select Control dialog box displays, as shown in Figure 5-2.

    Figure 5-2 Select Control Dialog


    Select Control Dialog

  6. Expand the desired folder to view the custom Java controls for WebLogic Portal that you can choose from.

After you add a custom WebLogic Portal control, all the methods in the control become available to your Page Flow.

For more information about the custom controls provided by WebLogic Portal, refer to the Portal Development Guide. For details about each control, refer to the Javadoc. (Links to the Javadoc for each of the controls packages are conveniently listed in the Javadoc Overview frame.)

 


Portlet State Persistence

You can control portlet state persistence using the persistence-enabled attribute in the netuix-config.xml file, which is located by default in the WEB-INF directory. Using this attribute causes the state to be saved in the WebLogic Portal database. The attribute is set to false by default.

The following code segment shows an example of the attribute syntax:

<control-state-location>
<session persistence-enabled="true"/>
</control-state-location>

WebLogic Portal places an entry for the control tree state in the PROPERTY_KEY table, with the following PROPERTY_SET_NAME value:

 


Adding a Portlet to a Portal

In the development phase of the portal life cycle, you add portlets to a portal using the WorkSpace Studio workbench.

Note: A page must have a layout before you can add a portlet to it. The vertical or horizontal placement of portlets in a placeholder is determined by the selected layout for the page.

Follow these steps:

  1. In the Package Explorer view, double-click the portal (.portal file) to which you want to add the portlet.
  2. The portal displays in the editor.

  3. If your portal has multiple pages, click the desired page to select it.
  4. From the Design Palette view, drag the portlet (the .portlet file) onto the portal page at the desired location.
  5. Figure 5-3 shows an example of this step.

    Figure 5-3 Dragging a Portlet from the Palette onto a Portal Page in Editor View


    Dragging a Portlet from the Palette onto a Portal Page in Editor View

With the portlet selected, you can use the Properties view to customize desired portlet properties.

For detailed information about portlet properties, refer to Portlet Properties.

When you add a portlet to a page in the workbench editor, a reference to that portlet is added to the .portal file. You can use the .portal file as a template for creating desktops in the WebLogic Portal Administration Console. When a portal administrator creates a desktop based on that template, the portlet is added to the portal resource library where it can be added to pages in streaming desktops. For an overview of file-based portals compared with streaming portals, refer to the Portal Development Guide.

In the Staging phase of the portal life cycle, you use the WebLogic Portal Administration Console to configure portlets on desktops. A single portlet definition can be associated with one or more portals (desktops) by creating instances of the portlet. Each of these portlet instances can have its own “personality” and behavior as specified by a variety of different configuration options.

For details in adding a portlet to a portal desktop in the WebLogic Portal Administration Console, refer to Managing Portlets on Pages.

 


Deleting Portlets

To remove a portlet from a portal without deleting the portlet from your portal web project, right-click the portlet in the WorkSpace Studio workbench editor and click Delete.

To delete a portlet from your portal web project, right-click the portlet in the Package Explorer view and choose Delete.

To remove a portlet after you have assembled portlet instances into portal desktops using the Administration Console, refer to Deleting a Portlet.

 


Advanced Portlet Development with Tag Libraries

During the Development phase, you can use tag libraries to add features to a GroupSpace Community, a custom Community, or a portal web application. This section discusses the following tag libraries:

See the Communities Guide for additional information.

Adding ActiveMenus

You can add the ActiveMenus JSP tag library to a GroupSpace Community, a custom Community, or a portal web application.

The ActiveMenus JSP tag library lets you set up a popup menu that displays when the mouse hovers over specific text. An activemenus-config.xml file controls the contents of each menu. The activemenus_taglib.jar file contains the ActiveMenus tag library.

By default, a GroupSpace Community has ActiveMenus enabled, so you only need to configure the ActiveMenus tag (see Configuring the ActiveMenus Tag). See Figure 5-4 for an example of the ActiveMenus tag in a GroupSpace Community.

Figure 5-4 ActiveMenus in the GS Issue Portlet

ActiveMenus in the GS Issue Portlet

You can tie a user’s capability to the ActiveMenu that you see when you hover your mouse over an item (an Issue, for example) and hover over the arrow that appears. In this example, if your assigned capabilities include the ability to delete items, you will see the Delete choice, as shown in Figure 5-4.

Tip: You do not need to perform the following steps if you have a GroupSpace Community; ActiveMenus are enabled by default for GroupSpace Communities.

Perform the following steps to enable ActiveMenus in a custom Community:

  1. In WorkSpace Studio, make the activemenus_taglib.jar file available to your portal web project. When you create your portal web project, you must enable the GroupSpace facets by selecting the WebLogic Portal Collaboration check boxes.
  2. Add the activemenus-config.xml file to your /WEB-INF directory in your portal web project. Add the file by right-clicking the activemenus-config.xml file and choosing Copy To Project. Configure the file by follow the instructions in Configuring the ActiveMenus Tag to edit the activemenus-config.xml file.
  3. Register the GetActiveMenusResourceServlet by adding the servlet and servlet-mapping to the web.xml file in the /WEB-INF directory in your portal web project. You can edit the file in WorkSpace Studio by double-clicking the web.xml file. Right-click the web-app line in the file and choose Add Child > message-destination - welcome-file-list > servlet. Add GetActiveMenusResourceServlet to the servlet-name line. Add com.bea.apps.groupspace.servlets.GetActiveMenusResourceServlet to the servlet-class line. See Figure 5-5 to view the edited file in WorkSpace Studio.
  4. Figure 5-5 Editing the web.xml File in WorkSpace Studio


    Editing the web.xml File in WorkSpace Studio

    The code sample in Listing 5-1 shows the new information you added.

    Listing 5-1 Code Sample of GetActiveMenusResourceServlet
    <!-- ActiveMenus Servlet Mappings -->
    <servlet>
    <servlet-name>GetActiveMenusResourceServlet</servlet-name>
    <servlet-class>
    com.bea.apps.groupspace.servlets.GetActiveMenusResourceServlet
    </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>GetActiveMenusResourceServlet</servlet-name>
    <url-pattern>GetActiveMenusResourceServlet</url-pattern>
    </servlet-mapping>
  5. Redeploy the application for the changes to take effect.

After you enable the ActiveMenus, you must configure the ActiveMenus tag.

Configuring the ActiveMenus Tag

To use the ActiveMenus tag, you must set up the activemenus-config.xml file (the XSD that defines this config file is located in the activemenus_taglib.jar file as activemenus-config.xsd). This activemenus-config.xml file file must exist in your web application's /WEB-INF directory. Multiple menus can be set up that consist of completely different items, styles, and icons.

Use the following sections to configure the activemenus-config.xml file file:

Using The TypeInclude tag

Use the typeInclude tag to keep your configuration file clean. Rather than adding the type tag (see Using The Type Tag) you can add this tag and point its href attribute to an XML file (relative to the web application) that contains all of the type information. An example of the typeInclude tag is:

<typeInclude xhref="/WEB-INF/activemenuTypes/username.xml"/>.

You can also use the type tag with the typeInclude tag in the configuration file. See the code sample in Listing 5-2.

Listing 5-2 You Can Use the typeInclude Tag with the Type Tag in the activemenus-config.xml File
<typeInclude xhref="/WEB-INF/activemenuTypes/username.xml"/>
<type>
<menuItem>
<param name="linkId"/>
<action action="editLink">
<i18nNamebundleName="com.bea.apps.groupspace.links.
LinksPopupMenu" key="edit.link"/>
</action>
<img xsrc="wlpAppsCollaborationCore/images/wlp-edit-16.gif"/>
</menuItem>
</type>

When you point to another XML file, ensure that you namespace it correctly, as shown in Listing 5-3.

Listing 5-3 Pointing to Another XML File Called username.xml
<type name="username"
xmlns="http://www.bea.com/servers/apps/groupspace/ui/
activemenus-config/9.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/servers/apps/groupspace/ui/
activemenus-config/9.0">
...
</type>
Using The Type Tag

The type tag defines the individual menus to use within the web application. The name attribute must be unique for each menu, because the name is how the menu is referenced when you use the ActiveMenus tag. Following is an example of the type tag:

<type name="foo">
</type>
Note: The TypeDefault and MenuItem tags must be contained within the type tag.
Using The TypeDefault Tag

The typeDefault tag defines what displays in the browser where the ActiveMenus tag is used. You can control the text that displays, the style of the text, and the image that appears on the mouseover of that text (which denotes the menu itself).

The following items display within the browser where you used the ActiveMenus tag:

Note: The TypeDefault and MenuItem tags must be contained within the type tag.
Using The menuItem Tag

The menuItem tag defines the individual items within the popup menu. Listing 5-4 shows a code sample using the menuItem tag.

Listing 5-4 The menuItem Tag
<menuItem>
<param name="userId"/>
<xmlHttp url="GetFirstNameServlet"/>
<row class="menuRow" style="backround-color:red"/>
<text class="menuText" style="color:#000000"/>
<rowRollover class="menuRowRollover" style="background-color:green"/>
<textRollover class="menuTextRollover" style="color:#FFFFFF"/>
</menuItem>
<menuItem>
<javascript>
<name>Testing</name>
<script>testing(this);</script>
</javascript>
</menuItem>
<menuItem default="true" showMenuItem="false">
<param name="q" value="foo"/>
<link url="http://www.google.com">
<name>Google</name>
</link>
</menuItem>
<menuItem>
<showMenuItem className="com.foo.CheckUserRights" methodName=
"doesUserHaveRights">
<rights name="can_view"/>
<rights name="can_edit"/>
</showMenuItem>
<allParams/>
<action action="addEditLink" disableAsync="true">
<i18nName bundleName="com.foo.LinksPopupMenu" key="edit.link"/>
</action>
</menuItem>
<menuItem>
<allParams/>
<dcAction action="showFeedData" dcContainerId="feedDataContainer">
<i18nName bundleName="com.foo.LinksPopupMenu" key="show.
feedData"/>
</dcAction>
</menuItem>

The menuItem tag defines the individual items within the popup menu with the following four types:

Note: The TypeDefault and MenuItem tags must be contained within the type tag.

Using the ActiveMenus Tag

The taglib.tld file is located in the activemenus_taglib.jar file.

You can use the following attributes and elements with the ActiveMenus tag:

Notes: If a class is specified on the tag, the default class specified in the activemenus-config.xml file is overridden and the default style is not placed on the activename. If a style is specified on the tag, the default class is placed on the activename. If a class="" is specified on the tag, the default class is not placed on the activename.

Enabling Drag and Drop

You can use the DragDrop JSP tag library to enable drag and drop functionality in a GroupSpace Community, a custom Community, or a portal web application. You must identify draggable objects that are displayed on a JSP, and identify drop zones that are configured to react to a dropped draggable object. The drop zones react by triggering Page Flow actions, calling JavaScript functions, or posting data to a servlet.

Perform the following actions before you use the DragDrop tag library:

Using the DragDrop Tags

Three tags are defined in the DragDrop tag library. Following are descriptions of how each tag is used, along with sample JSP code:

Using the dragDropScript Tag

You must include the dragDropScript tag before you use any other DragDrop tags on the page. This tag ensures that the appropriate JavaScript libraries are included. The dragDropScript tag does not take any attributes.

The following example shows how to use the dragDropScript tag: <dragdrop:dragDropScript/>.

Using the draggableResource Tag

The draggableResource tag specifies a draggable resource on the page. The tag takes the following attributes:

The draggableResource tag performs a search for a child img tag that has a dragdrop:image attribute. This image becomes the image that is displayed while performing the drag operation. The image must have an absolute height and width attribute.

The resourceId value is accessible through the JavaScript function getSourceId(), when the value is dropped onto a resourceDropZone. The resourceId value is also available as a parameter in the request named sourceId, when it is dropped onto a resourceDropZone that triggers a POST action. See Listing 5-7.

Listing 5-7 The sourceId Request Dropped onto a resourceDropZone
<dragdrop:draggableResource imageId="0" resourceId="${id}"resourceName=
"${name}">
<img src="/image.gif" width="16px" height="16px"dragdrop:image="true"/>
${name}
</dragdrop:draggableResource>
Using the resourceDropZone Tag

The resourceDropZone tag identifies an area where draggable resources can be dropped.

The tag takes the following attributes:

Only one of the following attributes is required: jsFunctionCall, pageFlowAction, or formAction. The jsFunctionCall takes precedence, then pageFlowAction, and finally formAction.

The targetId value is accessible through the JavaScript function getTargetId() when a draggable resource is dropped. It is also available as a parameter in the targetId request when a draggable resource is dropped that triggers a POST action. The following code shows how this works:

<dragdrop:resourceDropZone targetId="${id}" pageFlowAction="moveIssue">
<img src="/folder.gif"/>Issues Folder
</dragdrop:resourceDropZone>

Listing 5-8 demonstrates how the moveIssue action can be coded in a file called IssuesPageFlowController.java.

Listing 5-8 Coding the moveIssue Action
@Jpf.Action(forwards={ @Jpf.Forward(name = "success", path =
"displayIssuesTree.do")})
protected Forward moveIssue() {
Forward forward = new Forward("success");
String sourceId = getRequest().getParameter("sourceId");
String targetId = getRequest().getParameter("targetId");
move(sourceId, targetId);
return forward;
}

Enabling Dynamic Content

You can use the DynamicContent tag library to quickly update parts of a JSP page in a GroupSpace Community, a custom Community, or a portal web application.

The DynamicContent tags let you use an AJAX request to update part of a JSP page within a Page Flow-based portlet. The tags allow parts of the page to be updated without performing a full portal request. These AJAX requests are smaller and faster than full portal requests, and therefore provide a more responsive user experience when interacting with a portal application.

These tags are easy to incorporate into standard Page Flow-based portlet development and can help create advanced user interface features that improve a user’s portal experience.

Note: The DynamicContent tags are not related to Asynchronous Portlet Content Rendering. Asynchronous portlets allow for the entire portlet content to be rendered independently of the portal. The DynamicContent tags are designed to affect small parts of a JSP page within a portlet.

Understanding the DynamicContent Tags

This section describes the main tags in the DynamicContent tag library.

The Container Tag

The Container tag designates a place on the JSP page that contains the HTML output from the execution of a Page Flow action. The only required attribute for this tag is a container id. This id is referenced by other DynamicContent tags to identify the container. The following code shows how this tag is used: <dc:container dcContainerId="outputContainer"/>.

The Container Action Script Tag

This tag is a child of the Container tag and identifies a Page Flow action that can be executed and whose HTML output is placed inside the parent container. The containerActionScript tag takes the following attributes:

Only the action attribute is required. The following code sample shows how this tag is used in the parent Container tag:

<dc:container dcContainerId="outputContainer">
<dc:containerActionScript action="resetDynamicContentContainer"
initial="true"/>
<dc:containerActionScript action="showServerTime"/>
<dc:container/>
The Execute Container Action Tag

The Execute Container Action tag is used to create a call to a specific action inside a container. This tag takes the following attributes:

The dcContainerId and action attributes are required. Following is a sample of how this tag is used:

<dc:executeContainerAction action="showServerTime" dcContainerId=
"outputContainer"
var="showServerTimeVar"/>

In the previous example, the call to the specified action is stored in the variable showServerTimeVar. This variable can then be referenced, as shown in the following HTML code:

<form>
<input type="button" onclick="${showServerTimeVar}" value="Show Server
Time"/>
</form>

When the user clicks a button, an AJAX request is created that executes the showServerTime action and places the HTML output generated by that action into the container with the id of outputContainer.

The Parameter Tags

The DynamicContent tags also include tags for parameters that are passed into the action through the request. You can define parameters within the executeContainerAction tag or the containerActionScript tag. These parameters are then accessible in the Page Flow action by calling the request.getParameter() method.

Using the DynamicContent Tags

Some critical limitations are associated with the DynamicContent tags. The AJAX requests used to trigger the Page Flow actions are not processed through the main portal servlet. These requests go through a special servlet that performs some processing to ensure that the proper Page Flow instance is used. Many key elements that are normally available in the request are not accessible from these AJAX requests. For example, in Community-based portal applications, the CommunityContext object is not accessible from the AJAX request. The lack of access to some of these framework elements could have an impact on things like entitlements and security.

Because of these limitations, the DynamicContent tags are best suited for specific uses that involve small amounts of processing, with few dependencies on larger framework services. The following use cases could benefit from the DynamicContent tags:

See dev2dev for sample code and utilities contained in the sample.zip file.

Using the User Picker

During the Development phase, you can use the UserPicker tag library to add a form button to a JSP page in a GroupSpace Community, a custom Community, or a portal web application.

The UserPicker:popupButton tag provides the developer with the ability to add a form button to a JSP page which opens a popup window that displays a list of current users. You can select a user from this list. The name of the selected user is populated into a specified form field on the parent window.

Using the UserPicker Tags

This section describes the UserPicker:popupButton tag in a custom Community and how to use the following attributes:

Tip: When the UserPicker:popupButton tag is used in a Community, the Community members are listed, rather than users.

 


Importing and Exporting Java Portlets

WorkSpace Studio lets you import and export Java (JSR168) portlets. You can import Java portlets from a Web Archive (WAR), Java Archive (JAR), or ZIP file directly into your workspace. WorkSpace Studio automatically creates .portlet files for all imported Java portlets, making them available for immediate use in your portal. You can also export Java portlets from your workspace to a supported archive file.

Note: Throughout this section, supported archive files refer to WAR, JAR, and ZIP files.

By default, WorkSpace Studio imports and exports the portlet.xml, any Java class files required by the portlet, and any Java source files. Also, if any class or source Java files are found within a JAR or ZIP archive, that archive is also imported or exported. You can optionally specify additional files to be imported or exported. Once exported, a Java portlet contained in a supported archive file can be used with any compatible web server.

Tip: You can use the JSR168 Import utility to deploy a Java portlet contained in a supported archive file directly to a WebLogic Server instance. Once deployed with this utility, the portlets can be available to consumers through WSRP. For more information on this utility, see Using the JSR168 Import Utility.

Importing Java Portlets

To import Java portlets packaged in a supported archive file into your WorkSpace Studio workspace:

  1. Select File > Import. You can also right-click in the Project Explorer and select Import > Import...
  2. In the Import dialog, open the Other folder and select Portlet(s) from Archive.
  3. In the Select Project dialog, select the web project in which to place the imported Java portlets. Select the Overwrite existing resources without warning checkbox to force the import tool to overwrite duplicate files automatically, as shown in Figure 5-42.
  4. Figure 5-42 Select Project Dialog


    Select Project Dialog

  5. In the Select Archive dialog, select from your system a supported archive file (WAR, JAR, or ZIP) containing Java portlets, and click Next. The Select Portlet(s) dialog appears, as shown in Figure 5-43.
  6. Note: If the selected archive does not contain any Java portlets, then no standard artifacts will be selected. This is because the default archive format plugin does not recognize the archive as a Java portlet archive. In this case, the wizard allows you to select an archive format and allows you to select files manually to import. This is not a typical use case.
    Figure 5-43 Select Portlet(s) to Import Dialog


    Select Portlet(s) to Import Dialog

  7. If you have more than one archive format plugin. If you have multiple plugins installed that recognize the archive file as a Java portlet archive, then the Select Format dialog appears. Use this dialog to pick the archive format plugin you wish to use.
  8. In the Select Portlet(s) dialog, select the portlets to import. You must select at least one portlet. The Target Path specifies where, relative to the WebContent root, to place the portlet(s).
  9. Tip: You can create a new folder for your imported portlets simply by typing the folder name in the Target Path field. For example, if you enter /portlets, then the folder WebContent/portlets will be created and the portlet(s) will be placed in that folder. You can assign a specific target path to one or more portlets simply by selecting the portlet(s) and entering a target path. The Reset button restores the original path. You can multi-select a group of portlets and assign a target path to the selected group.
  10. Click Next.
  11. (Optional) If the supported archive file contains any optional files to that you want to import, select them and specify a target path relative to the WebContent root.
  12. Tip: Optional files are any files in the supported archive file that were not specified as required in the Import Template. The default Import Template requires the archive to contain a portlet.xml file and any class files required by the portlet.
    Tip: If you develop your own custom import plugin, it will also show up in the dropdown list of formats in the Select Format dialog. You can create a custom portlet import plugin if you want to specify the format of the imported archive and the default format is not sufficient. To create the plugin, you need to implement the PortletImporterPlugin interface. For more information, refer to the Javadoc on this interface.
  13. Click Finish. The portlet files are imported from the supported archive file, and .portlet files are created automatically in your workspace.
Tip: If you encounter problems with the import, it is possible that the a conflict exists with artifacts that already exist in your project workspace. In this event, use the Back button to change the target paths of conflicting artifacts, or select the wizard option on the Select Project dialog that forces the wizard to overwrite existing resources (see Figure 5-42).

Exporting Java Portlets

You can export Java portlets to a new or existing supported archive file (WAR, JAR, or ZIP). To export Java portlets to a supported archive file:

  1. Select File > Export. You can also right-click in the Project Explorer and select Export > Export...
  2. In the Export dialog, open the Other folder and select Portlet(s) to Archive.
  3. In the Select Portlets dialog, select the web project that contains the Java portlet(s) you want to export. You can select the parent folder that contains the portlet(s) or drill down to select individual portlets, as shown in Figure 5-44. Any portlets and/or parent folders that were selected in the Project Explorer will be pre-selected by default.
  4. Select the Overwrite existing resources without warning checkbox to force the export tool to overwrite duplicate files automatically.

    Note: All selected portlets must exist within the same Web project. You cannot select portlets for export across different Web projects.
    Figure 5-44 Select Portlet(s) to Export Dialog


    Select Portlet(s) to Export Dialog

  5. Click Next. The Edit Title(s) dialog appears, as shown in Figure 5-45.
  6. Figure 5-45 Edit Title(s) Dialog


    Edit Title(s) Dialog

  7. In the Edit Title(s) dialog, you can add or modify the Title and/or Description of an exported portlet. These fields are written to the exported portlet’s portlet.xml file. Click Next to continue.
  8. Note: A Title is required for each portlet. If any Title field is blank, the Next button is disabled until you supply a title.
  9. In the Select Archive dialog enter a full path and name for the archive file, or use the Browse button to specify the path, and click Next. If the archive does not exist, the wizard will prompt you to create it.
  10. In the Select Format dialog, pick the archive format that you want to use and click Next. A default format is provided.
  11. Tip: If you develop your own custom export plugin, it will also show up in the dropdown list of formats in the Select Format dialog. You can create a custom portlet export plugin if you want to specify the format of the exported archive and the default format is not sufficient. To create the plugin, you need to implement the PortletExporterPlugin interface. For more information, refer to the Javadoc on this interface.
  12. In the Select Files dialog, select any optional supporting files, such as JSPs, that you wish to include in the supported archive file. Any files that are included in the selected archive format (such as portlet.xml) are automatically selected in the dialog. You can associate a Target Path path with any selected files. Those files will be placed in the specified target path within the archive file. By default, all files are stored relative to the root directory of the archive.
  13. Click Finish. The archive file is created in the location you specified.

Using the JSR168 Import Utility

WebLogic Portal provides a utility for automatically deploying JSR-168 portlets that are packaged in JSR-168 WAR files. This utility lets you import JSR-168 WAR files containing JSR-168 portlets, and expose the portlets in WSRP producers. For detailed information on this utility, see the chapter “Deploying Portal Applications” in the Production Operations Guide.


  Back to Top       Previous  Next