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

I'd like to render a pageBlock only when there is an error.

I really want to display a pageBlock only when ApexPages.hasErrors() is true.


At this stage, I can only think of putting a hasErrors boolean in my controller extension and accessing the property with 


<apex:pageBlock rendered="[!hasErrors}">   but can I access the ApexPages.hasErrors directly from VisualForce?


Am I overlooking something really obvious?



           This is sample code for workround on visibility of pageblock.

           VF CODE:

                                   <apex:pageBlock rendered="{!Propset}"/>

                                   controller code:

                                   you can check getter and setter property in controller

                                   Public boolean Propset{get;set;}

                                   public void dummy()




                                                    Propset = true;




Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.


In the end I just did this.



<pageBlock rendered="{!hasErrors}">





	public Boolean hasErrors { get { return ApexPages.hasMessages(); } }



Seems concise and to the point.