Monday, August 12, 2013

Changing or setting up Page Title of a JSR-286 Portlet dynamically

Hello Friends,

To write into the HTML head section of your JSR 286 portlet, for example, to change a page title, use the addProperty method on the PortletResponse.

Invoke the addProperty method to modify the HTML head section.

PortletReponse.addProperty(String key, org.w3c.dom.Element element)

Note: When modifying the HTML head section, you must invoke the addProperty method before the response headers are committed. This should occur no later than during the render headers sub phase of the render lifecycle phase.

Example:

protected void doHeaders(RenderRequest request, RenderResponse response)
{
    Element title = response.createElement("title");
    title.setTextContent("My Portal Page Title");
    response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, title);
}

Thanks,
Chirag

2 comments:

  1. Very interesting blog. A lot of blogs I see these days don't really provide anything that attract others, but I'm most definitely interested in this one. Just thought that I would post and let you know.

    ReplyDelete