Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
liferay developer
SessionMessages
April 7, 2010 7:58 AM
Answer

liferay developer

Rank: New Member

Posts: 12

Join Date: March 30, 2010

Recent Posts

Hi there,

Need to customize login portlet in Liferay 5.2.3 working with the extension environment
One of the things I need to do is to display a session message or an error message like this ones:





For the error message (the red ones) I did it like this and it is working fine:

in processAction method of the Action:

if (condition) {
throw new MarketingCustomAttributeAlreadyAssignedException();
}

and in the correspondant jsp:

<liferay-ui:error exception="<%= MarketingCustomAttributeAlreadyAssignedException.class %>" message="marketing.error.custom-attribute-already-asigned" />

and that is working fine


But for the green ones what I tried after look at the source code is this but does not work:

in processAction method of the Action:

SessionMessages.add(actionRequest, "mensaje-de-prueba");

in the correspondant jsp:

<c:if test='<%= SessionMessages.contains(request, "test-message-01") %>'>
<span class="portlet-msg-info">
<liferay-ui:message key="test-message-01" />
</span>
</c:if>

in Language-ext.properties:

test-message-1=Hello

But nothing is displayed

Any help? Or another way to do it?

thanks in advance
Wilson Man
RE: SessionMessages
April 7, 2010 3:05 PM
Answer

Wilson Man

LIFERAY STAFF

Rank: Liferay Master

Posts: 580

Join Date: June 21, 2006

Recent Posts

liferay developer:
in processAction method of the Action:

SessionMessages.add(actionRequest, "mensaje-de-prueba");

in the correspondant jsp:

<c:if test='<%= SessionMessages.contains(request, "test-message-01") %>'>
<span class="portlet-msg-info">
<liferay-ui:message key="test-message-01" />
</span>
</c:if>


those should be the same.
liferay developer
RE: SessionMessages
April 8, 2010 2:18 AM
Answer

liferay developer

Rank: New Member

Posts: 12

Join Date: March 30, 2010

Recent Posts

Thanks but that was not the problem. Yes of course the key should be the same, that was just a copy paste error when copy here but that is not the reason.

Anyway I found the reason that is:

SessionMessages.add(actionRequest, "test-message-01");

It shoud not be actionRequest but the request from HttpServletRequest Class that it can be obtained from actionRequest like this:

HttpServletRequest servletRequest = PortalUtil.getHttpServletRequest(
actionRequest);

And then doing this:

SessionMessages.add(servletRequest, "test-message-01");

is working fine

but thanks
Wilson Man
RE: SessionMessages
April 9, 2010 12:04 PM
Answer

Wilson Man

LIFERAY STAFF

Rank: Liferay Master

Posts: 580

Join Date: June 21, 2006

Recent Posts

i was able to use actionRequest to set the Session Message.
(disregard my previous post about private-request-attribute since that wouldn't help).
I'll let you know when i find the solution so you don't need to touch the HttpServletRequest directly.
Riley Pickerl
RE: SessionMessages
September 4, 2013 8:35 AM
Answer

Riley Pickerl

Rank: Junior Member

Posts: 50

Join Date: January 10, 2013

Recent Posts

Hi there I am trying to set session messages from a portlet in vaadin. I am having no problem setting and getting the message, however I do not have any jsp so I am not sure how to make the liferay UI display the messages on request. Is there a way to tell liferay to display the sessionmessages in the ui from java and not jsp?

Thanks
David H Nebinger
RE: SessionMessages
September 4, 2013 8:54 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11046

Join Date: September 1, 2006

Recent Posts

Hey, Riley, the Vaadin portlet you create is totally responsible for the UI. Liferay will not inject elements into your UI, so you're going to have to take care of this yourself. That said, you can add the Liferay styles to labels to get them to render in the green, yellow, and red colors.
Riley Pickerl
RE: SessionMessages
September 4, 2013 9:19 AM
Answer

Riley Pickerl

Rank: Junior Member

Posts: 50

Join Date: January 10, 2013

Recent Posts

Darn, I was fearing that to be the answer. It seems strange that there is no API call that can trigger showing the Liferay messages.
Thanks for the quick response David!
David H Nebinger
RE: SessionMessages
September 4, 2013 9:44 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11046

Join Date: September 1, 2006

Recent Posts

Well, it's implemented using the Liferay tag library. You need to manually insert them into your JSP pages, too. There's nothing automatic about it...

If you were doing JSF, ZK, or any other framework you'd be left to rendering it manually, too...