function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Melissa Mueller 9Melissa Mueller 9 

I am seeing the Visualforce page message in my debug logs but cannot get it to display on the page!

I have asked this question on salesforce.stackexchange.com approximately 10 days ago. I received some feedback and edited my code. I still can't get error messages to display and controller no longer calls my apex code! Could someone, anyone, look over the updated code and see if you can tell why this is happeninig or how I can fix it? I would really appreciate the help! The question is here:  https://salesforce.stackexchange.com/questions/192422/i-am-seeing-the-visualforce-page-message-in-my-debug-logs-but-cannot-get-it-to-d
Alain CabonAlain Cabon
Hi Melissa,

I noticed immediately that in your code: <apex:page standardController="Case" extensions="CaseControllerExt" Title="New Warranty Claim" showHeader="false" id="createNewWarranty" docType="html-5.0">

<Apex:pageMessages/> not working if showHeader=“false”​
"For some reason, messages created inside the constructor are not displayed when the page header isn't shown. If you move that to a method and add it to your actions, it will work. Also, you need to load the standard style sheets since they are usually included with the header. If you don't it looks ugly." Daniel Hoechst
https://salesforce.stackexchange.com/questions/15167/apexpagemessages-not-working-if-showheader-false

If your code has been updated (without showHeader="false" now), please post the complete current code here.

public with sharing class CaseControllerExt {
   public CaseControllerExt(ApexPages.StandardController controller){  // ... and that is your constructor.

Regards
Melissa Mueller 9Melissa Mueller 9
Alain,
First, let me thank you for taking the time to respond. I have read your post and the referenced question with solution from someone else, but I am confused. The code in that example is so basic I am not sure how to relate it to my code. To start, I took the code that you have seen and changed showHeader to true. (The header looks just fine without doing anything else and I don't really care if it's there or not.) That let my code call the apex again, but as expected, since I have no units listed as faulty, a debug log apex error is thrown after it passes the if statement that should throw a visible error message and escape out of the code. That if statement seems to be passed right over and instead the code continues and dies when it executes the next statement that should only be executed if that error isn't thrown. No error message that is visible to the user is displayed, however, I can see it in the debug log. Ugh...  

If I move the error calls to their own method, I am guessing that I should be calling them from their respective catch or if statements. That would mean that each different message I want to display would need its own method.... Am I on the right track? If so, do I call from the Apex class and have all the error message methods on the controller or should they reside elsewhere?
Alain CabonAlain Cabon
There is nothing about this problem in the documentation but that could be an issue and  Daniel Hoechst knew this problem (perhaps solved since 2013). If you have tested wihout  showHeader="false", you can confirm that this problem is solved ... or not.
It is will be difficult to reproduce your problem.
Melissa Mueller 9Melissa Mueller 9
The problem is not solved. I do think I now have enought to go on to get it working.... hopefully! I will post the corrected code when I get it to work. Not sure why, in all my googling, that I hadn't found that post before. So, Alain, thank you for showing it to me.
Melissa Mueller 9Melissa Mueller 9
I tried adding the action to the VF page and having it call a separate method from the controller and the message displays, but, it always displays! I can't have that. I need the error message to only display when there is an actual error!