1

I have a requirement where I want a section to render depending on a value of a controller variable. If the section is not rendered I want an error message to be displayed. I have the following piece of code

<apex:pageblock rendered="{!AModel.enableSection}"> 

I want something like this

if enablesection is true render page block else display String message 'Section cannot be rendered'

1 Answer 1

0
<apex:pageblock rendered="{!AModel.enableSection}"> <apex:pageMessages rendered="{!NOT(AModel.enableSection)}"/> 

Use apexPageMessage with Rendered

And in controller use

ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Section cannot be rendered')); 
2
  • How would I pass the static value to the page message? I would not be able to return it form a method Commented Jun 16, 2016 at 11:11
  • @Rimii you need to use ApexPages.addMessage to add the pageMassage in your page. Commented Jun 16, 2016 at 11:12

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.