0

I'm trying to change the title of the page, but the method PortalUtil.setPageTitle("title", request); is not working from the jsp. I also tried in the doView method.

My second attempt was throught servletrequest:

In doView I wrote

HttpServletRequest httpRequest = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest));
httpRequest.setAttribute("hola", "hola");

And in the portal normal I tried with:

#set ($holas =$request.get('attributes').get('hola'))
#set ($holas2 = $request.getSession().getAttribute("hola"))

$holas    
$holas2

but Velocity only shows $holas $holas2.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Antonio mc
  • 85
  • 1
  • 12

3 Answers3

1

Looks like I got it wrong in my first attempt - thus I've replaced the previous answer with this one: Add this code to your JSP or doView:

<% 
com.liferay.portal.util.PortalUtil.setPageTitle("Honk", request); 
%>
Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
  • Javascript is not an option, because Google doesn't read js. Could you please explain the other way? is it possible in doView inside XXXportlet.java? – Antonio mc Jul 09 '13 at 13:59
0

In your jsp you should try

<%
layout.setTitle("title");
%>

layout is an Layout object generated by jsp.

Babesh Florin
  • 226
  • 1
  • 11
0

Use below code,

String title = (String)renderRequest.getAttribute("title");
HtmlPageTitleUtil.setHtmlTitle(title, request, true);

Pass title attribute from the controller or you can use static text as well. Import the above utility class as well as,

<portlet:defineObjects />
<theme:defineObjects />

this to jsp and its done.

Abhishek Suthar
  • 674
  • 1
  • 8
  • 27