Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Using SessionErrors to pass custom error messages Eric Soucy October 28, 2008 10:24 AM
RE: Using SessionErrors to pass custom error messages MANOVINAYAK AYYAPPAN July 5, 2011 7:35 PM
RE: Using SessionErrors to pass custom error messages Jitendra Rajput July 6, 2011 11:40 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 11, 2011 8:57 AM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 11, 2011 12:54 PM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 11, 2011 1:01 PM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 11, 2011 11:18 PM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 12, 2011 4:07 AM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 12, 2011 4:17 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 12, 2011 4:42 AM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 12, 2011 6:23 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 12, 2011 6:25 AM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 12, 2011 6:45 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 12, 2011 6:50 AM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 12, 2011 6:55 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 12, 2011 7:24 AM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 13, 2011 10:31 AM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 19, 2011 11:52 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 20, 2011 2:38 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 24, 2011 6:17 AM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 25, 2011 4:24 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 26, 2011 1:54 AM
RE: Using SessionErrors to pass custom error messages Sarika Nair August 29, 2011 4:05 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 29, 2011 4:42 AM
RE: Using SessionErrors to pass custom error messages Sarika Nair August 29, 2011 4:47 AM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 29, 2011 5:04 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 29, 2011 5:10 AM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 29, 2011 5:41 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 29, 2011 5:47 AM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 29, 2011 6:18 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 29, 2011 7:03 AM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 29, 2011 7:13 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 29, 2011 7:55 AM
RE: Using SessionErrors to pass custom error messages Sagar A Vyas August 29, 2011 9:52 AM
RE: Using SessionErrors to pass custom error messages Jonny Olliff-Lee August 30, 2011 12:11 AM
RE: Using SessionErrors to pass custom error messages Adrian Dumitroaia April 20, 2012 12:20 AM
Eric Soucy
Using SessionErrors to pass custom error messages
October 28, 2008 10:24 AM
Answer

Eric Soucy

Rank: New Member

Posts: 14

Join Date: October 8, 2008

Recent Posts

Hello,
I have a JSF portlet and I want to use SessionErrors to add my own error messages and show them using liferay-ui:message tag.

I tried doing SessionErrors.add() but i don't see my message showing up.

I tried this in the code:
SessionErrors.add(request, "customloginportlet.thismessage");
String tmp = (String) SessionErrors.get(request, "customloginportlet.thismessage");

and then i checked if my resource was read:
PortletConfig config = (PortletConfig) request.getAttribute("javax.portlet.config");
ResourceBundle rb =config.getResourceBundle(request.getLocale());
tmp = rb.getString("customloginportlet.thismessage");

I also checked:
LanguageUtil.get(request.getLocale(), "customloginportlet.thismessage");

All of this(code above) is working fine. But I always end up with my portlet showing only :
You have entered invalid data. Please try again.

If I do :
SessionErrors.clear(request);
SessionErrors.add(request, "customloginportlet.thismessage");

then i don't see any message showing up.

Can someone help me?
MANOVINAYAK AYYAPPAN
RE: Using SessionErrors to pass custom error messages
July 5, 2011 7:35 PM
Answer

MANOVINAYAK AYYAPPAN

Rank: Regular Member

Posts: 132

Join Date: June 13, 2011

Recent Posts

Hi Eric,

Did you resolve this issue ?

I am facing the same problem.

The standard error message "You have entered invalid data. Please try again. " keeps coming up instead of my custom error message that I have setup using SessionErrors.add(actionRequest, error);

Please help,

Regards,
Mano
Jitendra Rajput
RE: Using SessionErrors to pass custom error messages
July 6, 2011 11:40 AM
Answer

Jitendra Rajput

Rank: Liferay Master

Posts: 873

Join Date: January 7, 2011

Recent Posts

You can display custom error message using this way

1) SessionErrors.add(portletRequest , error.key);
2) Go to your Jsp where you want to display this message and use this tag
<liferay-ui:error key="error.key" message="error.message"></liferay-ui:error>

3) and write complete message inside language.properties for this key
error.message = Custom Message


Thanks
Jitendra
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 11, 2011 8:57 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

I'm having this exact same issue, and I've read a lot of posts that say the same thing as Jitendra has suggested, but I still can't get it to work! I'm trying to post errors on the Configuration Screen and in my ConfigurationActionImpl class I have:

1 SessionErrors.add(actionRequest, "bad-bcc-address");


The in my configuration.jsp file I have:

1<liferay-ui:error key="bad-bcc-address" message="please-enter-a-valid-email-address"></liferay-ui:error>


Can anyone see what's going wrong? I'm still just getting the default Liferay error message rather than the please-enter-a-valid-email-address one that is another standard Liferay one. This problem is driving me up the wall!!

I'm running Liferay 5.2.3 on Tomcat 6, and working with a portlet developed in the plugins-sdk? Thoughts anyone?
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 11, 2011 12:54 PM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Hi Jony ,

Your code look fine.

I guess you have to make sure by putting debugging in your eclipse that following line is execute or not ?

SessionErrors.add(actionRequest, "bad-bcc-address");


Because this in only probably case, it will not show any massage if it will not add any in session.

So make sure that your line is execute properly

Thanks,
Sagar Vyas
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 11, 2011 1:01 PM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

Hi Sagar,

I'm all but certain the line is executing because there is code following is running! I will run the server under debug mode tomorrow to make sure. This is the problem, the code looks fine but it just doesn't work.

Thanks for your input!

Jonny
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 11, 2011 11:18 PM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Hi Jonny,

I can help you out if you share your java code snippet.

Thanks,
Sagar Vyas
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 12, 2011 4:07 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

Hi Sagar,

I can't share the whole code because it's owned by my employers blah blah blah, but here's the parts that are relevant:

Amongst other things I try to send an email to and from a blank email address, causing a javax.mail.internet.AddressException to be thrown.
1
2MailEngine.send(new InternetAddress(fromAddress), new InternetAddress(fromAddress),
3                        "Valid From Address", "Congratulations, your BCC address is valid!");

Then the following exceptions are caught afterwards, and I'm interested in AddressException in particular.
 1
 2} catch (AddressException ex) {            
 3            SessionErrors.add(actionRequest, "bad-bcc-address");
 4            _log.error("AddressException thrown in processAction: " + ex);            
 5        } catch (IOException ex) {
 6            _log.error("IOException thrown in processAction: " + ex);
 7            SessionErrors.add(actionRequest, "error");
 8        } catch (ValidatorException ex) {
 9            _log.error("ValidatorException thrown in processAction: " + ex);
10            SessionErrors.add(actionRequest, "error");
11        } catch (ReadOnlyException ex) {
12            _log.error("ReadOnlyException thrown in processAction: " + ex);
13            SessionErrors.add(actionRequest, "error");
14        } catch (SystemException ex) {
15            _log.error("SystemException thrown in processAction: " + ex);
16            SessionErrors.add(actionRequest, "error");
17        } catch (MailEngineException ex) {
18            _log.error("MailEngineException thrown in processAction: " + ex);
19            SessionErrors.add(actionRequest, "error");
20        } catch (PortalException ex) {
21            _log.error("PortalException thrown in processAction: " + ex);
22            SessionErrors.add(actionRequest, "badthankyou");
23        }


The log statement afterwards is run, so I know the code is running. Then on my configuration.jsp I have:

<liferay-ui:error key="bad-bcc-address" message="please-enter-a-valid-email-address"></liferay-ui:error>

Do you need more than this? Thanks for your help Sagar!
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 12, 2011 4:17 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Hi Jonny,

Welcome Jonny emoticon

Do one thing jonny,

I think it will not execute this line "SessionErrors.add(actionRequest, "bad-bcc-address");"

To make sure it do something as below

catch (Exception ex)
{
SessionErrors.add(actionRequest, "bad-bcc-address");
}

and try , I am sure it will work.

do it like mention and then we will debug further.

Thanks,
Sagar Vyas
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 12, 2011 4:42 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

Thanks Sagar!

I've been around for a while, just not had much need to ask questions! :-)

Right I've added the catch for Exception, and the log is throwing the same error javax.mail.internet.AddressException (which I was expecting because I'm purposely causing the exception) but the error message is still the same.

This is why it's driving me nuts, because it should work!! :-\

Thanks!
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 12, 2011 6:23 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Right I've added the catch for Exception, and the log is throwing the same error javax.mail.internet.AddressException


Hey Are you using mail functionality ?
Please add mail.jar in your lib of portlet.

Thanks,
Sagar Vyas
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 12, 2011 6:25 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

I am, and I already have. My code sends the mail without issue. What I am trying to do though is throw up the error message if a blank email address is used. That is how I am deliberately causing the AddressException to be thrown.

Thanks,
Jonny
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 12, 2011 6:45 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Ok got it thanks for elaborating it.

I guess you have already observed that this log get print at your console _log.error("AddressException thrown in processAction: " + ex); did you ?

Or what you can do check manually that given address is empty if yes then add key inside the sessionError ?

Thanks,
Sagar Vyas
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 12, 2011 6:50 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

I should have probably stated that in the first place! :-\

Yes, the log message is most definitely appearing. Okay I shall do a nullOrEmpty check on the address field! Good plan!!

Thanks,
Jonny
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 12, 2011 6:55 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Hey Jonny,

I would more happy ,If you get resolved it .

Just let me know once you have done with it successful emoticon

Thanks,
Sagar Vyas
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 12, 2011 7:24 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

Hey Sagar!

I'd certainly be happy if I could resolve it. Well I've tried to a null or empty check on the field, but all I get is the default Liferay Error message not the one I want! :-(

Can you confirm that this does actually work in Liferay 5.2.3?

Thanks,
Jonny
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 13, 2011 10:31 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Can you confirm that this does actually work in Liferay 5.2.3?


Ok Jonny , I will defiantly test and let you know.
For that i have to configure Liferay 5.2.3 and then need to test and get back to you.

Thanks,
Sagar Vyas
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 19, 2011 11:52 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Jonny Olliff-Lee:
Hey Sagar!

I'd certainly be happy if I could resolve it. Well I've tried to a null or empty check on the field, but all I get is the default Liferay Error message not the one I want! :-(

Can you confirm that this does actually work in Liferay 5.2.3?

Thanks,
Jonny



HI Jonny ,

Any luck with your issue ?

I have tried with specified version it is working fine for me ?


Thanks,
Sagar Vyas
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 20, 2011 2:38 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

Sagar A Vyas:

HI Jonny ,

Any luck with your issue ?

I have tried with specified version it is working fine for me ?


Thanks,
Sagar Vyas


Hi Sagar,

Nope, not luck yet! I might try this weekend with some test code, and see if I can get it working. I've got to be missing something!

Thanks for your help Sagar!

Jonny
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 24, 2011 6:17 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

Sagar A Vyas:
Jonny Olliff-Lee:
Hey Sagar!

I'd certainly be happy if I could resolve it. Well I've tried to a null or empty check on the field, but all I get is the default Liferay Error message not the one I want! :-(

Can you confirm that this does actually work in Liferay 5.2.3?

Thanks,
Jonny



HI Jonny ,

Any luck with your issue ?

I have tried with specified version it is working fine for me ?


Thanks,
Sagar Vyas



Hi Sagar,

Well I've just thought I'd give it a go with another portlet I'm working on. Guess what, it works!!! I have no idea why the other one doesn't work but never mind.

Now all I've got to do is get the default error message to disappear when a custom one is used!

Thanks again for your help!

Regards,
Jonny
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 25, 2011 4:24 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Well I've just thought I'd give it a go with another portlet I'm working on. Guess what, it works!!!


Hey Jonny,

Good to hear it works now emoticon

Thanks,
Sagar Vyas
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 26, 2011 1:54 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

Well I guess I spoke to soon!

For the portlet where I have got it working, I've only got it working in the view.jsp, however when an error is thrown in the configuration.jsp it doesn't show! :-( They both reference the same init.jsp which is declaring everything that is needed, but one works and the other doesn't.

Any ideas?
Sarika Nair
RE: Using SessionErrors to pass custom error messages
August 29, 2011 4:05 AM
Answer

Sarika Nair

Rank: Junior Member

Posts: 38

Join Date: October 5, 2009

Recent Posts

Hi....

i have added the session error in the catch block of action servlet

catch (Exception ex)
{
SessionErrors.add(actionRequest, "ErrorMessage");
}


and added the following line in jsp:

<liferay-ui:error message="No Search Result !!!" key="ErrorMessage" />


I am getting both the error messages on my screen,default as well as customized one.
How can i get rid of the default message "You have entered invalid data. Please try again. " ??
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 29, 2011 4:42 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

Sarika Nair:
Hi....

i have added the session error in the catch block of action servlet

catch (Exception ex)
{
SessionErrors.add(actionRequest, "ErrorMessage");
}


and added the following line in jsp:

<liferay-ui:error message="No Search Result !!!" key="ErrorMessage" />


I am getting both the error messages on my screen,default as well as customized one.
How can i get rid of the default message "You have entered invalid data. Please try again. " ??


Hi Sarika,

That's a good question, and one I think everyone who uses liferay-ui:error must ask!! The best way to get rid of it, is to use a Hook to override the JSP found on the path:

portal-web\docroot\WEB-INF\jsps\html\taglib\ui\error\end.jsp

so that the default error message doesn't appear if there is another message to display. You might want to keep it as a default message though. I have no idea why Liferay have decided to keep that message being displayed when there is another one, it seems a little crazy to me!

I found this on another thread here: http://www.liferay.com/community/forums/-/message_boards/message/10131239

Hope that helps!!

Jonny
Sarika Nair
RE: Using SessionErrors to pass custom error messages
August 29, 2011 4:47 AM
Answer

Sarika Nair

Rank: Junior Member

Posts: 38

Join Date: October 5, 2009

Recent Posts

Hi Jonny....

Thanks for such a prompt reply....
will try out hooks...

will update the status once done... emoticon
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 29, 2011 5:04 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Hi Sarika,

You can also refer following discussion

http://www.liferay.com/community/forums/-/message_boards/message/5368483


Jonny ,
We have requirement where we are not suppose to create ext or hook.

In this case what should I do ? If you have any idea please share emoticon

Thanks,
Sagar Vyas
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 29, 2011 5:10 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

Sagar A Vyas:


Jonny ,
We have requirement where we are not suppose to create ext or hook.

In this case what should I do ? If you have any idea please share emoticon

Thanks,
Sagar Vyas


Hi Sagar,

Well that's a pretty steep requirement, I can understand not using ext, but why aren't you allowed to create hooks? Hooks were created so you didn't have to use ext!!

Your only other options are :

1) Change the default message in the your Language.properties files (but this doesn't help as you still have the same message throughout)

2) Alter the source code for the hat jspf file (but this is a bad idea, especially if you're not allowed to use ext or hooks)

3) Use JavaScript to hide the other error, while displaying the one you want.

4) USE A HOOK!!!

What is the reasoning behind not using hooks? That seems like a really bad requirement.

Jonny
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 29, 2011 5:41 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Hi Jonny,

Thanks for such nice description

No they dont want to mess with OOB code whether it is Java class or Jsp.

As per them if you need to change any single jsp file then just develop new portlet rather change in OOB emoticon Strange but True emoticon

So as your described above.

I have to use jQuery or JS (What I am using right now).

But Curious to know if any property is available which i can put into liferay-portlet.xml and make it work.

Anyways Thanks again for reply.

Thanks,
Sagar Vyas
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 29, 2011 5:47 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

Sagar A Vyas:
Hi Jonny,

Thanks for such nice description

No they dont want to mess with OOB code whether it is Java class or Jsp.

As per them if you need to change any single jsp file then just develop new portlet rather change in OOB emoticon Strange but True emoticon

So as your described above.

I have to use jQuery or JS (What I am using right now).

But Curious to know if any property is available which i can put into liferay-portlet.xml and make it work.

Anyways Thanks again for reply.

Thanks,
Sagar Vyas


That really is a shame, especially as with a Hook you can add logic in there to say only do this behaviour for this particular portlet ID (and therefore not changing the OOB behaviour, and only changing it for your portlet). Very strange, never mind!!

Yes, you'll have to use jQuery or plain old JavaScript to hide the error, and unfortunately there's nothing that I know of in the liferay-portlet.xml that can change or hide the default error.

One thought I have just had though, is maybe the possibility of removing the default Error from SessionErrors. So when you add you're message, you remove the default one. Not too sure if it would work (or even if it's possible) but worth looking in to!

Jonny
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 29, 2011 6:18 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Hi Jonny,

I think they are right on their way.

Cause what happen is we have community (almost 10 communities) structured now consider scenario.

If they want to use OOB Portlet A for Community X and Now For Community Y you need to use same portlet.

Now just assume that your are change some jsp by creating hook for Portlet A it will reflect also in Community Y even they dont want emoticon

This is reason emoticon

We are using following way to change it

1$('.portlet-msg-error').each(function(index,value){
2    var errorText = $(this).text().trim();
3    if(errorText=="You have entered invalid data. Please try again."){
4        $(this).remove();
5    }
6});


Thanks,
Sagar Vyas
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 29, 2011 7:03 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

Sagar A Vyas:
Hi Jonny,

I think they are right on their way.

Cause what happen is we have community (almost 10 communities) structured now consider scenario.

If they want to use OOB Portlet A for Community X and Now For Community Y you need to use same portlet.

Now just assume that your are change some jsp by creating hook for Portlet A it will reflect also in Community Y even they dont want emoticon

This is reason emoticon

We are using following way to change it

1$('.portlet-msg-error').each(function(index,value){
2    var errorText = $(this).text().trim();
3    if(errorText=="You have entered invalid data. Please try again."){
4        $(this).remove();
5    }
6});


Thanks,
Sagar Vyas


Okay, I know where you're coming from. I support & develop 3 separate fairly similar code bases which are used by 100+ communities. Trying to keep all 3 bases the same is a huge task, and most of the changes were done in EXT before I got there so there is a lot of modified OOB functionality.

So when you have your situation where portlet A is being used by Community X & Community Y, but only Community X wants the change then you develop your Hook with two addition methods, 1 checks the portlet ID, the second checks the groupId (ThemeDisplay.getScopeGroupId()). If they those two match Portlet A & Community X then you override the default behaviour, if not then you leave it alone.

There are two reasons I would strongly push for this over using jQuery or plain JavaScript. The first is that if the viewer has JavaScript turned off, you've lost your change in functionality. The second is that in this instance you are only changing the text of an error message, not actual functionality of the portlet. Surely each time that error occurs, then same message should be displayed (and the default one hidden) no?

Jonny
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 29, 2011 7:13 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Hi Jonny,

Thanks for suggestion.

You are absolutely right buddy no doubt on that. but they don't want move like extra methods
1 checks the portlet ID, the second checks the groupId
,Though i will suggest your way.

Thanks for details.

Thanks,
Sagar Vyas
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 29, 2011 7:55 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

Hi Sagar,

No worries, sounds like I have a little more control over what goes into the code. Who is "they" exactly? Well I just wanted to make sure we'd explored all possibilities for you! emoticon

Jonny
Sagar A Vyas
RE: Using SessionErrors to pass custom error messages
August 29, 2011 9:52 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Hi Jonny,

You already explored all possibilities.

Appreciated your help.

I can not declare those information , Its confidential sorry emoticon

Thanks,
Sagar Vyas
Jonny Olliff-Lee
RE: Using SessionErrors to pass custom error messages
August 30, 2011 12:11 AM
Answer

Jonny Olliff-Lee

Rank: Junior Member

Posts: 48

Join Date: January 25, 2011

Recent Posts

Hi Sagar,

Ah fair enough, I understand. Well thanks for your help with the SessionErrros issue as well!

Thanks,
Jonny
Adrian Dumitroaia
RE: Using SessionErrors to pass custom error messages
April 20, 2012 12:20 AM
Answer

Adrian Dumitroaia

Rank: New Member

Posts: 1

Join Date: March 15, 2012

Recent Posts

To show custom message one more thing need to be added in portlet.xml .
After <suports></suports> add <resource-bundle>content.Language</resource-bundle>. And custom message will be read it from Language.properties.
The same system work for SessionMessages.add(request, "key") too.