You can also insert pagelets into non-proxied pages using
a simple javascript function.
To activate this feature, add the following HTML snippet in the
<HEAD> section of the page.
<script type="text/javascript" src="http://proxy:port/inject/v2/csapi">
</script>
This script injects all CSAPI and pagelet inject functions into
the page to display the pagelet. One of the sections injected is the
following function:
function injectpagelet(library, name, injectmethod, payload, arguments)
{
...
}
This function injects an Ensemble pagelet as a widget
into the parent page. The method interface is as follows:
- library: The library name of the pagelet to inject. This
argument is a string that accepts spaces like 'library name'.
- name: The name of the pagelet to inject. This argument
is a string that accepts spaces like 'pagelet name'.
- injectmethod: Specifies the manner of injecting the pagelet,
if set to 'iframe', then an iframe is inserted where the call occurs,
otherwise inline HTML will be used. If the inject method is specified
as 'iframe', then a set of IFrame options can be sent along. These
options control how the iframe will be displayed. The following iframe
options are supported: width, height, frameborder, align, longdesc,
marginheight, marginwidth, scrolling, stylem class. The parameters
are given in the form of param=value. The separator
between parameters are spaces. For example, 'iframe align=right
frameborder=1 width=100% height=200 scrolling=yes class=myclass'.
- payload: The XML payload to send along with the pagelet
request
- arguments: The pagelet arguments to send along with the
pagelet request. Should be given in the form of: 'param1=value1¶m2=value2¶m3=value3'.
The script also creates a new <div> with a unique name that
includes a reference to the
injectpagelet function.
Several examples are shown below:
<div>
<script type="text/javascript">
injectpagelet('library', 'name');
</script>
</div>
<div>
<script type="text/javascript">
injectpagelet('library', 'name', 'iframe', 'payload', 'param1=value1¶m2=value2¶m3=value3');
</script>
</div>
<div>
<script type="text/javascript">
injectpagelet('library', 'name', 'iframe width=100% height=200', 'payload');
</script>
</div>