Using Portlets from the Portlet Library

The Portlet Library contains a variety of pre-built portlets that you can bring into your portal application and modify. These portlets are examples of commonly used webapp functions, and should help you get a quick start on building the components for your portal.

To examine the available portlets, select File > Open > Application from the top-level menu in the WebLogic Workshop IDE. Browse to the following folder, and select the portalApp.work file:

<BEA_HOME>/<WEBLOGIC_HOME>/samples/portal/portalApp

When the application is open in the IDE, navigate to the /sampleportal folder, and open the sample.portal file. In the Data Palette pane shown here, the IDE displays the portlets used in sampleportal, which comprise the Portlet Library.

In the IDE, you can drag and drop a portlet from the Portlet Library to a region, or placeholder, on your open portal page.

A number of these portlets are described in the Sample Portal topic. A table identifies the files that comprise the portlet, and the corresponding location in your portal application where you should install or copy the files. Typically this process involves the following:

  • Copying the *.portlet file to your <PORTAL_APP>/<project>/portlets/includes folder.
  • Copying one or more *.jsp file(s) to your <PORTAL_APP>/<project>/portlets folder.
  • In some cases, copying a *.java backing file to your <PORTAL_APP>/<project>/
    WEB-INF/src/<path>/... folder.
  • In some cases, copying a JAR used by the portlet to your <PORTAL_APP>/<project>/WEB-INF/lib folder.

If you are working in another enterprise application on your system — separate from the sample portalApp that contains the Portlet Library — you can use the IDE File > Import Files... feature to copy a portlet's files into your web project.

For example in a web project of another enterprise application, you could add a /portlets folder, right-click on that folder name and select Import... from the menu. Then browse to the following directory:

<BEA_HOME>/<WEBLOGIC_HOME>/samples/portal/portalApp/sampleportal/portlets

In the display of portlet folders, select the folder that contains the portlet you want to import into your application. Note, however, that the Import operation simply copies the files in the folder that you selected. You may need to also import or copy related files, such as a source *.java backing file used by the portlet. Here is an example of the files needed for the Login Director portlet:

Import or copy this to this directory (create if necessary)

<WEBLOGIC_HOME>/samples/portal/portalApp/
sampleportal/portlets/login/director.portlet

<PORTAL_APP>/<project>/portlets/login/
<WEBLOGIC_HOME>/samples/portal/portalApp/
sampleportal/portlets/login/director.jsp
<PORTAL_APP>/<project>/portlets/login/
<WEBLOGIC_HOME>/samples/portal/portalApp/
sampleportal/WEB-INF/src/examples/login/DirectorBacking.java
<PORTAL_APP>/<project>/
WEB-INF/src/examples/login/
<WEBLOGIC_HOME>/samples/portal/portalApp/
sampleportal/WEB-INF/src/examples/login/DirectorUtil.java
<PORTAL_APP>/<project>/
WEB-INF/src/examples/login/

This type of information is presented for many of the portlets in the samples Help topics. Start in Sample Portal.

You cannot use the Import feature to copy in a portlet that already exists in the current enterprise application; WebLogic Workshop will display this message:

The easiest method is to use the file system to simply copy the files that comprise the portlet to your web project's folders. Again, in many cases there are more files than the *.portlet and *.jsp file(s) that comprise the portlet. For details, see the each topic listed in Sample Portal.

Related Topics

Sample Portal

Creating Portlets

Customizing Portlets