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. Since many URL-based applications (including Google.com) can take in parameters (through GET or POST), you may want to pass parameters to your URL-based application. With PDK-URL Services, you can pass parameters to your URL-based portlet. The values for these parameters can be provided by the provider XML file, or by the portal user at runtime.
This article describes how to build a URL-based portlet that handles parameter passing. It extends the sample found in the article How to Build a URL-Based Portlet. Instead of using Google.com as the URL-based application, this article uses Yahoo! Maps (http://maps.yahoo.com).
You have successfully installed the PDK-Java runtime and samples by following the article Installing the PDK-Java Framework and Samples.
You have successfully installed the PDK-URL Services runtime and samples by following the article Installing the PDK-URL Services Samples
You have successfully installed the Google.com URL-based portlet by following the article How to Build a URL-Based Portlet.
This section explains how to create an XML provider definition for your URL-based portlet provider.
The following sample is the same as that found in the article How to Build a URL-Based Portlet. However, for illustration purposes, the sample here has replaced Google.com with the URL for Yahoo! maps (http://maps.yahoo.com). In addition, it uses the inputParameter tag to specify the parameters that this portlet can receive. 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>Parameter Portlet</name>
<title>Parameter Portlet</title>
<description>Display Yahoo! Maps as a portlet.</description>
<timeout>100</timeout>
<timeoutMessage>Timed out waiting for Yahoo! Maps 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>
<inputParameter class="oracle.portal.provider.v1.URLPortletParameter">
<name>csz</name>
<isMandatory>false</isMandatory>
<displayName>What location do you want a map for (City, State or Zip)?</displayName>
</inputParameter>
<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://maps.yahoo.com/py/maps.py</pageUrl>
<filter class="oracle.portal.provider.v1.http.HtmlFilter">
<headerTrimTag><body</headerTrimTag>
<footerTrimTag>/body></footerTrimTag>
<inlineRendering>true</inlineRendering>
</filter>
</showPage>
</renderer>
</portlet>
</provider>
|
Save the file as "provider.xml", making sure it overwrites the provider.xml file you created in the article How to Build a URL-Based Portlet.
You should have already configured and registered the Google.com
portlet provider according to the article How
to Build a URL-Based Portlet.
You may reuse this provider and simply rename it to reflect the changes made above. To do this, you need to:
Stop and restart the Oracle HTTP Server
Edit the portlet provider via the Edit Provider screen, i.e. change the name from Google.com to "Yahoo! Maps" or "Paramater Passing Portlet Provider".
You are now ready to add the parameter passing portlet to a page.
The parameter passing feature of PDK-URL Services provides a variety of options for passing parameters to your URL-based portlets.
<inputParameter class="oracle.portal.provider.v1.URLPortletParameter">
<name>csz</name>
<isMandatory>true</isMandatory>
<displayName>What location do you want a map for (City, State or Zip)?</displayName>
</inputParameter>
<inputParameter class="oracle.portal.provider.v1.URLPortletParameter">
<name>csz</name>
<isMandatory>false</isMandatory>
<displayName>What location do you want a map for (City, State or Zip)?</displayName>
<value>94065</value>
</inputParameter>
<showEdit>true</showEdit> ... <inputParameter class="oracle.portal.provider.v1.URLPortletParameter"> <name>csz</name> <isMandatory>true</isMandatory> <displayName>What location do you want a map for (City, State or Zip)?</displayName> </inputParameter> ... <editPage class="oracle.portal.provider.v1.http.URLEditRenderer"> ... <personalizationManager class="oracle.portal.provider.v1.FilePersonalizationManager"> <dataClass>oracle.portal.provider.v1.http.URLPersonalizationObject</dataClass> <useHashing>true</useHashing> </personalizationManager>
Whenever default parameter values or customization of parameter values are used, parameter values are determined by the following order of precedence:
- Portlet page parameters received through the HTTP request.
- Default values specified in provider.xml.
- Customized parameter values.
For more information and illustrated examples, see Understanding Portal Page and Portlet Parameters in PDK-URL Services.
Now that you have successfully added parameter passing 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, HTML and XML filtering and more.
Here are some reference articles to help you better understand the architecture and technical details of PDK-URL Services:
Revision History:
November 2001