Oracle WebCenter Interaction Web Service Development Guide

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

Oracle WebCenter Interaction Scripting Framework Development Tips

These tips and best practices apply to all code that utilizes the Oracle WebCenter Interaction Scripting Framework.

Use unique names for all forms and functions. Use the GUID of a pagelet/portlet to form unique names and values to avoid name collisions with other code on the page. You can append the pagelet/portlet ID using the pt:namespace and pt:token tags, as shown in the code below.
<pt:namespace pt:token="$$TOKEN$$" xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/'/>
<a onclick="doStuff$$TOKEN$$();" href="#">do stuffa onclick="doStuff$$TOKEN$$();" href="#">do stuff</a>
<script>
function doStuff$$TOKEN$$() {
alert("hello");
}
</script>
Valid values for the token are in the ASCII range 0x21 to 0x7E, excluding "<" (0x3C). The scope of the token runs from the tag defining it to the end of the file; you cannot use a token prior to defining it. A second pt:namespace tag with a different token redefines it; two tokens cannot be defined at the same time.
Gateway all URLs. You cannot make a request to a URL whose host/port differs from that of the calling page. All URLs requested through JavaScript must be gatewayed. For details on the gateway, see About Pagelets/Portlets and the Gateway.
Check for Scripting Framework support. It is good practice to include code that determines whether or not the component is present. Ideally, your pagelet/portlet should be able to handle either situation. The simplest solution is to precede your code with an If statement that alerts the user if the Scripting Framework is not supported.
<script>
if (PTPortlet == null) 
  {
  if (document.PCC == null) 
    {
    alert("This portlet only works in portals that support the JSPortlet API or Portlet
    Communication Component (PCC). The portlet will be displayed with severely reduced
    functionality. Contact your Administrator.");
    }
  }
else 
  {
  [scripting code here]
  }
</script>
Close all popup windows opened by a portlet when the portal window closes. The Scripting Framework can be used to close popup windows using the onunload event.
Do not assume that browsers will process script blocks/includes added through the innerHTML property. Add all required JavaScript to the page in advance:
  • IE: Add the defer attribute to the script tag.
  • Netscape: Use RegExp to parse the response and look for the script, then eval it.

  Back to Top      Previous Next