You need to sign in to do that
Don't have an account?
aj2taylo2
Return Page Error From Public Void
I have a VF Extension class with subclass, that has a void method.
public with sharing class myWizard { public myWizard(ApexPages.StandardController stdController) { ... } public List<listMap> getHierarchy() { ... return returnList; } // ------------------------------------------------------ // Custom class for the Gantt Chart Projects // ------------------------------------------------------ public class listMap { public listMap(...) { instantiateValues(); } private void instantiateValues() { ... } public void addChild() { try { ... } catch (Exception e) { if(e.getTypeName() != 'System.DmlException') { this.myRecord.addError(e.getMessage()); } } } } }
When the void method (addChild) from my VF Page, I want to return an error for an Exception. Is there a way I can do this?
Try highlighted changes. Your visualforce page must have a <apex:pageMessages/> tag.
Hit the Kudos button if any post helps you - Mark the answer as solution, It might help others running to into similar problem in future.
All Answers
Try highlighted changes. Your visualforce page must have a <apex:pageMessages/> tag.
Hit the Kudos button if any post helps you - Mark the answer as solution, It might help others running to into similar problem in future.
Thanks chamil; unfortunately, that doesn't return the error to the page.
Actually, I got it working by removing the condition around DMLException. Thank you!