Changing title of portal page

The JSR 286 specification has a concept of two phase rendering, you can use it to add element in the portal document's head section, one use case for doing that would be if you want to change the title of the portal page.

I wanted to try that so i created this like this



import javax.portlet.GenericPortlet;
import javax.portlet.MimeResponse;
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.w3c.dom.Element;

public class TwoPhaseRenderingPortlet extends GenericPortlet{
protected void doHeaders(RenderRequest request, RenderResponse response) {
System.out.println("Entering TwoPhaseRenderingPortlet.doHeaders()");

Element title = response.createElement("title");
title.setTextContent(" portal page");
response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, title);

System.out.println("Exiting TwoPhaseRenderingPortlet.doHeaders()");
protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
System.out.println("Entering TwoPhaseRenderingPortlet.doView()");
response.getWriter().println("Hello from two phase rendering portlet");
System.out.println("Exiting TwoPhaseRenderingPortlet.doView()");

In the TwoPhaseRenderingPortlet, i am overriding doHeaders() method and inside the method, first i am creating a title element then i am setting the value of that element to portal page and the last step is to call response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, title); method which asks the RenderReponse object to insert newly created title element in the head section of the document.

Once the portlet is deployed i tried accessing it and i can see that the title that i set is displayed in the title bar of the browser, also when i tried looking at the source code i could see that the <title> element is added


rajesh said...

Does the tow-phase rendering is supported in WP 6.1.5? I dont see such a comment in the infocenter, but it does not work for me. Can someone confirm this?

Unknown said...

That's great I've been looking for this king of functionality for a while.

Now quick the question:

Does the 286 implementation of WCM leverage such functionality in ordert to allow me to set that title too?

nithin said...

Didn't work for me :(
I'm using Websphere Portal 6.1.

Armando Picón said...

it works fine in WP 8.0 :)

srjwebsolutions said...

We are leading responsive website designing and development company in Noida.
We are offering mobile friendly responsive website designing, website development, e-commerce website, seo service and sem services in Noida.

Responsive Website Designing Company in Noida
Website Designing Company in Noida
SEO Services in Noida
SMO Services in Noida

Vikas Chaudhary said...

Battery Mantra is Authorized exide car battery dealer in Noida and Greater Noida. We are providing our service in Indirapuram, Delhi, Ashok Nagar.

Exide Battery Dealer in Noida
Battery Dealer in Noida
Authorized Battery Dealer in Noida
Car Battery Dealer in Noida
Car Battery Dealer
Exide Battery Dealer

EG MEDI said... is online medical store pharmacy in laxmi nagar Delhi. You can Order prescription/OTC medicines online.
Cash on Delivery available. Free Home Delivery

Online Pharmacy in Delhi
Buy Online medicine in Delhi
Online Pharmacy in laxmi nagar
Buy Online medicine in laxmi nagar
Onine Medical Store in Delhi
Online Medical store in laxmi nagar
Online medicine store in delhi
online medicine store in laxmi nagar
Purchase Medicine Online
Online Pharmacy India
Online Medical Store