Oracle9iAS Portal Developer Kit
How to Build a URL-Based Portlet with HTML Filtering

In the article, How to Build a URL-Based Portlet, you learnt how to create a portlet that displayed the content of a URL-based application.  The example used in that article was Google.com.  In some situations, you may wish to display selective HTML content from the application on which your portlet is based.  For example, you may wish to filter out unwanted header or footer information before displaying the application content within the portlet.  PDK-URL Services provides a framework which enables you to apply such HTML filtering to your URL-based portlets. 

 

This article describes how to build a URL-based portlet that uses HTML filtering.  It extends the Google.com sample from the article How to Build a URL-Based Portlet.  Specifically, it uses HTML filtering to filter all content from Google except for the search form.  The resulting URL-based portlet will just show the text box, the "Google Search" and "I'm Feeling Lucky" buttons, and the few other links associated with a Google search.

ASSUMPTIONS

  1. You have successfully installed the PDK-Java runtime and samples by following the article Installing the PDK-Java Framework and Samples.

  2. You have successfully installed the PDK-URL Services runtime and samples by following the article Installing the PDK-URL Services Samples

  3. You have successfully installed the Google.com URL-based portlet by following the article How to Build a URL-Based Portlet.

CREATING AN XML PROVIDER DEFINITION

This section explains how to create an XML provider definition for your URL-based portlet provider.

  1. Using a text editor, create an XML file for your portlet provider.

      The following sample is the same one from the How to Build a URL-Based Portlet article.  It displays Google.com within the portlet.  However, this time it uses the headerTrimTag and the footerTrimTag to filter everything from Google.com except for the search form itself.  Please refer to the article Understanding provider.xml for PDK-URL Services for an explanation of the required XML tags and their functions.

    <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <?providerDefinition version="2.0"?>
    <provider class="oracle.portal.provider.v1.http.URLProvider">
       <session>true</session>
       <proxyInfo class="oracle.portal.provider.v1.http.ProxyInformation">
          <httpProxyHost>www-proxy.us.oracle.com</httpProxyHost>
          <httpProxyPort>80</httpProxyPort>
       </proxyInfo>
       <portlet class="oracle.portal.provider.v1.http.URLPortlet">
          <id>1</id>
          <name>Google.com Portlet</name>
          <title>Google.com Portlet</title>
          <description>Display Google.com as a portlet.</description>
          <timeout>100</timeout>
          <timeoutMessage>Timed out waiting for Google.com Portlet.</timeoutMessage>
          <acceptContentType>text/html</acceptContentType>
          <showEdit>false</showEdit>
          <showEditToPublic>false</showEditToPublic>
          <showEditDefault>false</showEditDefault>
          <showPreview>false</showPreview>
          <showDetails>false</showDetails>
          <hasHelp>false</hasHelp>
          <hasAbout>false</hasAbout>
          <renderer class="oracle.portal.provider.v1.RenderManager">
             <contentType>text/html</contentType>
             <showPage class="oracle.portal.provider.v1.http.URLRenderer">
                <contentType>text/html</contentType>
                <charSet>ISO-8859-1</charSet>
                <pageUrl>http://www.google.com</pageUrl>
                <filter class="oracle.portal.provider.v1.http.HtmlFilter">
                   <headerTrimTag>&lt;form</headerTrimTag>
                   <footerTrimTag>/form></footerTrimTag>
                </filter>
             </showPage>
          </renderer>
       </portlet>
    </provider>
  1. Save the file as "provider.xml", making sure it overwrites the provider.xml file you created from the article How to Build a URL-Based Portlet (you may wish to make a backup copy of the older provider.xml file).

ADDING THE URL-BASED PORTLET TO A PAGE

Since you configured and registered the Google.com portlet provider when following the article How to Build a URL-Based Portlet, you simply need to stop and restart the Oracle HTTP Server, refresh the portlet provider through the Edit Provider screen. Now you are ready to add the HTML-filtered Google.com portlet to a page.

Now that you have successfully added HTML filtering to your URL-based portlet, please look for other portlet development articles that describe how to add extra features to your portlet, including single sign-on to external URL-based applications, inline rendering, parameter passing, and more.

Here are some reference articles to help you better understand the architecture and technical details of PDK-URL Services:


Revision History: