Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 31st, 2012  |  syntax: None  |  size: 0.43 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How do I catch an exception being thrown in a setter bound to a VisualForce input?
  2. public Decimal latitude {
  3.   get {
  4.     return (Decimal)self.get('latitude__c');
  5.   }
  6.   set {
  7.     self.put('latitude__c', value);
  8.   }
  9. }
  10.        
  11. <apex:inputtext value="{!latitude}" />
  12.        
  13. try{
  14.    latitude = Decimal.valueOf(latitude);
  15. }catch (exception e){
  16.    ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.Error, 'Invalid latitude entered!'));  
  17. }