Changing the portlet title at runtime

0 comments



There are few options using which we can set portlet title dynamically.

1. By Overriding the GenericPortlet class method

@Override
protected String getTitle(RenderRequest request) {
// TODO we can fetch the Title from Edit Shared settings and return that title
return "newTitle";
}

2. Setting the title in the portlet skin

In the skin applied to that portlet, look at the control.jsp, there is a <wps:portlettitle> tag which render the title obtained from portlet.xml at run time.

We can add the attribute id="portlettitle" to the "div" surrounded by <wps:portlettitle> tag.

Now in the jsp at run time, using document.getElementById("portlettitle"), get the object and set its innerText/innerHtml to a different title.

No comments:

Post a Comment

Recent Posts

Popular Posts

© 2011-2019 Web Portal Club