Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Anonymous
Printing Error, Success, and Warning messages in portlets
May 27, 2011 12:24 AM
Answer

Anonymous

Good day,

In my portlet I want to use error messages and success messages like the default ones that are build into the native liferay portlets.
How exactly does one go about doing this?

At the moment I have the import statement in my JSP:
1<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>


And I try and display the success message as follow:
1<liferay-ui:success key="success" message="Tester success message!" />


But....It doesn't get displayed in my JSP page after re-deploying....Any ideas??

thanks in advance!
srikanth a
RE: Printing Error, Success, and Warning messages in portlets
May 27, 2011 12:59 AM
Answer

srikanth a

Rank: Regular Member

Posts: 142

Join Date: February 20, 2011

Recent Posts

Hi Dean,
As per your post, you want to display the success and error message in your portlet.
did you added those keys in the session. Could you please add them in the below way in your java class.

for success messages:=====> SessionMessages.add(actionRequest, "success");

for error messages :=====>> SessionErrors.add(actionRequest, "<key value>");

then try access them in the jsp using the "liferay-ui" tag.


hope it solves your problem.



regards
Sri
Anonymous
RE: Printing Error, Success, and Warning messages in portlets
May 31, 2011 12:33 AM
Answer

Anonymous

Hi Shri,

Thank you for your reply. I did add the actionRequest to the SessionMessages and did exactly what you said... I'm still not seeing the success or error messages in my portlet... On my portal page, I have two portlets that print success and error messages. Portlet A for example, works perfectly. Portlet B doesn't (even though I do EXACTLY the same thing in the code).

So I'm led to believe the problem has to something to do with the fact that there's more than one portlet on my page that makes use of the success and error messages...

Any other ideas/ How I can solve this?

Thanks agian.
Jan Gregor
RE: Printing Error, Success, and Warning messages in portlets
May 31, 2011 7:36 AM
Answer

Jan Gregor

Rank: Regular Member

Posts: 224

Join Date: October 20, 2010

Recent Posts

Hi there,

Well if you have already a mechanism for storing the error message in some bean, or request variable, you can just display your message using :

<span class="portlet-msg-error"><%=message%></span>

Instead of portlet-msg error you can use "portlet-msg-success" or "portlet-msg-warning".

If you are using jsp, the message variable should hold your message. This styles are defined in liferay theme.

Hope it helps.

Jan.
Hajri Mohamed
RE: Printing Error, Success, and Warning messages in portlets
June 21, 2011 5:12 PM
Answer

Hajri Mohamed

Rank: Junior Member

Posts: 71

Join Date: March 2, 2011

Recent Posts

thank you for this post, it was valuable for me,
just the portlet-msg-warning is not working for me, the two others are working well, any one that get the same issue ??
Nicola Baiocco
RE: Printing Error, Success, and Warning messages in portlets
December 17, 2013 8:18 AM
Answer

Nicola Baiocco

Rank: New Member

Posts: 3

Join Date: November 27, 2013

Recent Posts

You can use class="portlet-msg-alert" (in Liferay 6.0.6 works fine).