- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
11-13-2012 03:29 PM
I would like to create a VisualForce page using a standard controller, that captures and displays the page errors by using <apex:pageMessages />. Right now, if you call any VisualForce page but encounter an error, for ex calling the page with an invalid identifier, you get a standard Salesforce.com error message:
Id value 001U0000005W2cu1 is not valid for the Account standard controller
I would like for my page to display this error in the styles and configuration I've specified in the page, but instead, my page isn't shown and I get the Salesforce.com error instead.
This is possible using a custom controller, where I can trap any errors, add them to the pagemessages collection, then have my VF page check this collection to display the data or the error message using the proper formatting.
Appreciate any insight you might have...
11-14-2012 01:24 AM
I've written a couple of blog posts on this subject that my prove helpful:
Certified Salesforce Technical Architect, Developer, Advanced Developer, Administrator, Advanced Administrator, Consultant, Sales Cloud Consultant,Service Cloud Consultant
Force.com MVP | The Bob Buzzard Blog | Linked In | Twitter
I don't respond to private messages/emails asking for help.
Take the Bob Buzzard Sobject Fields quiz.
11-14-2012 09:32 AM
Thanks for your reply and the references. What'd I'd like to do though is to handle any errors from my VF page without using a custom controller (i.e. with the Account standard controller).
For example, with a custom controller I can do this:
...where PageHasError is a public property in my custom controller class that indicates whether there was a problem retrieving the account passed to the page from the url. This will allow my page to display the account details if the account id passed in exists, but will gracefully show the error if it doesn't - i.e. the error is displayed using my VF page formatting and so forth, the rest of my VF page is still rendered. When using a standard controller, there is no PageHasError property, and instead, VisualForce takes over and renders the error message in the standard Salesforce.com format, and no part of my page is rendered.