You need to sign in to do that
Don't have an account?

Display an exception message not working
I want to throw an exception when the list size is more than 5. This code is not working
--------------------------------------------------------
public PageReference addDealSplitAction(){
DealSplitWrapper dealSplit = new DealSplitWrapper(product);
try{
if(dealSplits.size()<6){
dealSplits.add(dealSplit);
throw new Exception('Test Common Exception'); // To throw if list size is greater than 5 ..not working
}
}catch(Exception ex) {
System.debug(ex.getMessage());
}
return null;
}
---------------------------------------------------------
Hi Rajeev,
you have to use <apex:pagemessages> tag in your VF page to display exception.
Apex Code:
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/
All Answers
Hi Rajeev,
you have to use <apex:pagemessages> tag in your VF page to display exception.
Apex Code:
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/
Update it to :
if(dealSplits.size()<6){
dealSplits.add(dealSplit);
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Test Common Exception')); // To throw if list size is greater than 5 ..not working
}
Tahnks Deepa