Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Laurent RUAUD
Dynamic portlet titles using Sun portlet container implementation
January 28, 2009 5:02 AM
Answer

Laurent RUAUD

Rank: New Member

Posts: 22

Join Date: May 5, 2008

Recent Posts

Hi all.

I was developping portlets which need to change their titles during render request processing.
I used RenderResponse.setTitle(String) but it did not work properly (titles were never changed).

Here a sample of what I was trying:
 1
 2public class TestPortlet extends GenericPortlet {
 3    @Override
 4    public void render(RenderRequest request, RenderResponse response)
 5            throws PortletException, IOException {
 6       
 7        String title = new Date().toString();
 8        response.setTitle(title);
 9        response.setContentType("text/html");
10
11        PrintWriter writer = response.getWriter();
12        writer.append("Title set to: " + title);
13        writer.flush();
14        writer.close();
15    }
16}


After some testing and checking, I found that my portal (a Liferay 5.1.2 instance) was set to use the Sun portlet container implementation.
Changing back to Liferay's custom implementation made my portlets work better.

Then, I'd like to ask a few questions:
- Does someone know if there is a way (configuration or else) to make this title stuff work with the Sun implementation ?
- Are there other functionnalities that may differ from Liferay's custom implementation ?

Thanks in advance for any answers.

Laurent.
Deepak Gothe
RE: Dynamic portlet titles using Sun portlet container implementation
January 28, 2009 10:33 PM
Answer

Deepak Gothe

Rank: Junior Member

Posts: 44

Join Date: May 19, 2008

Recent Posts

Hi,
In Liferay 5.1.2, Sun portlet container implementation was not fully integrated. There were some issues which was fixed on trunk, but didn't make it to 5.1 branch. Liferay 5.2 has the complete integration of Sun portlet container.
In Liferay 5.1.2 you may want to use Resource Bundle to set the title.

Does your portlet work as expected in OpenPortal Portlet Container?

Regards,
Deepak
Alex Wallace
RE: Dynamic portlet titles using Sun portlet container implementation
January 29, 2009 6:20 AM
Answer

Alex Wallace

Rank: Liferay Master

Posts: 640

Join Date: November 4, 2007

Recent Posts

Alternatively you could try changing the title using PortletPreferences...
Laurent RUAUD
RE: Dynamic portlet titles using Sun portlet container implementation
January 30, 2009 4:01 AM
Answer

Laurent RUAUD

Rank: New Member

Posts: 22

Join Date: May 5, 2008

Recent Posts

Hi Deepak.

Thanks for your explanations.

I tried with the new Liferay 5.2.0 and it works nicely!
I didn't tried in OpenPortal Portlet Container, it was easier for me to try the new Liferay.
I needed it for other enhancements so my problem's solved now.

Thanks again.

Laurent.
Laurent RUAUD
RE: Dynamic portlet titles using Sun portlet container implementation
January 30, 2009 4:07 AM
Answer

Laurent RUAUD

Rank: New Member

Posts: 22

Join Date: May 5, 2008

Recent Posts

Hi Alex.

What did you mean by using PortletPreferences?

I knew I could set the portlet title using one of these methods:
- in portlet.xml using <portlet><portlet-info><title>
- in the ResourceBundle declared in portlet.xml
- dynamically using RenderResponse.setTitle(String)
but didn't know yours.

Thanks.

Laurent.
Alex Wallace
RE: Dynamic portlet titles using Sun portlet container implementation
January 30, 2009 7:40 AM
Answer

Alex Wallace

Rank: Liferay Master

Posts: 640

Join Date: November 4, 2007

Recent Posts

When you manually change the title on the portlet title bar, this change is stored in PortletPreferences for the portlet instance, in the database...

In the same maner if you change the portlet preferences for your portlet instance, you will see the title change when viewing the portlet...

I hope this makes sense...

Thanks!
Laurent RUAUD
RE: Dynamic portlet titles using Sun portlet container implementation
January 30, 2009 7:57 AM
Answer

Laurent RUAUD

Rank: New Member

Posts: 22

Join Date: May 5, 2008

Recent Posts

Yes it is.

I wasn't aware of this; thanks for the info.
Anyway, I'm trying to make JSR compliant portlets and this will be too Liferay specific then.

Thanks again.

Laurent.