Help SiteVision 4

Rendering portlets

Portlet instances in SiteVision can be rendered either separately or as part of a page. Websites and pages are constructed using the SiteVision editor, which is used to create and configure individual portlet instances that can be placed in templates and pages.

Page rendering

To render a portlet as a part of a page simply point your browser to the URL of the page. That will cause all portlets in the template and the specific page to be rendered in sequence, according to the Portlet API specification.

Layout rendering

Portlet instances in a SiteVision page can be grouped into layouts, which specify the order and structure of the page. Sometimes it is useful to render a specific layout separately, usually in order to include it on another page or in a custom application as application content.

This can be accomplished by constructing the URL using the following rule:
Start with the URL of the page where the layout is located. Now insert "<name of layout>." before the extension of the page.

If you for example have a page with the following URL:

http://somehost/somepage/anotherpage.html
then you can render the "Top" layout of that page with the following URL:
http://somehost/somepage/anotherpage.Top.html
This will render the layout named "Top" and all portlets it contains. You can either reference the layout using its name or its id. The id can be found by viewing the HTML source of the page, and locating the "id" attribute of the div element that renders the layout. If the id of the layout is "10.da5992b1100cb1de6f800049" then the div id will be "svid10_da5992b1100cb1de6f800049". So, remove the "svid" prefix and replace the "_" with "." to get the original id to be used in the URL.
http://somehost/somepage/anotherpage.10.da5992b1100cb1de6f800049.html
When using the ".html" suffix the HTML content of the layout will be wrapped in HTML "html" and "body" tags so that a complete HTML document is output. This is useful if you want to render the layout in a popup window, for example.

If you are interested only in the raw layout output, for direct inclusion in another webpage for example, then you can instead use the ".portlet" extension, like this:

http://somehost/somepage/anotherpage.Top.portlet
Similarly, if you want only the raw text of the referenced layout you can use the ".txt" extension:
http://somehost/somepage/anotherpage.Top.txt

This will render the layout and portlets as HTML and remove the tags so that only the text content remains. The mimetype of the returned content will be "text/plain". Some portlets have specific support for this mimetype, such as the text and table portlets.

Note that these rules can be used no matter what URL style you have chosen for your website.

Portlet rendering

If you want to render a single portlet you can use the same strategy as with layouts, but include the name or id of the portlet you want to render instead. For example, if you have the following page:

http://somehost/somepage/anotherpage.html
and want to render only the "Header" portlet you can use this URL:
http://somehost/somepage/anotherpage.Header.portlet
This will render only the portlet named "Header". If you instead use the .html suffix the portlet content will be wrapped with "html" and "body" tags so that a complete HTML document is output.

You can specify what content type to return by adding the request parameter "sv.contenttype". If you want to render the "Header" portlet as text you can therefore use either of these URL's:

http://somehost/somepage/anotherpage.Header.portlet?sv.contenttype=text/plain
or
http://somehost/somepage/anotherpage.Header.txt

Creating portlet URLs

The easiest way to create URL's to portlets is to use the createRenderURL() method in the RenderResponse of your portlet. Here's an example:

PortletURL url = response.createRenderURL();
url.setWindowState(new WindowState("solo"));
url.toString();
The resulting URL can be used in link tags in HTML, or for AJAX calls. Typically you will want to open the URL in a new window, which you can achieve by using JavaScript.

The page published:

Find us!

SiteVision AB (Headquarter)
Vasagatan 10
702 10 Orebro
Sweden


Info: +46 19-17 30 30
Support: +46 19-17 30 39