Forum

Accueil » Liferay Portal » English » 3. Development

Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
Anonyme
Printing Error, Success, and Warning messages in portlets
27 mai 2011 00:24
Réponse

Anonyme

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
27 mai 2011 00:59
Réponse

srikanth a

Rang: Regular Member

Publications: 142

Date d'inscription: 20 février 2011

Publications Récentes

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
Anonyme
RE: Printing Error, Success, and Warning messages in portlets
31 mai 2011 00:33
Réponse

Anonyme

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
31 mai 2011 07:36
Réponse

Jan Gregor

Rang: Regular Member

Publications: 224

Date d'inscription: 20 octobre 2010

Publications Récentes

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
21 juin 2011 17:12
Réponse

Hajri Mohamed

Rang: Junior Member

Publications: 71

Date d'inscription: 2 mars 2011

Publications Récentes

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
17 décembre 2013 08:18
Réponse

Nicola Baiocco

Rang: New Member

Publications: 3

Date d'inscription: 27 novembre 2013

Publications Récentes

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