Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to view a section based on a condition ... but it seems that the Rendered statement always return false, I'm not sure where I went wrong! but could someone help me?

here is my code

     <!--the buttons block  -->
     <apex:pageBlockButtons >
       <apex:commandButton value="Save" action="{!save}"/>
       <apex:commandButton value="Cancel" action="{!cancel}"/>
     <!--end of buttons block -->  

 <apex:actionRegion >
   <!--Section 1 -->   
   <apex:pageBlockSection title="Basic Information" columns="2">

             <apex:inputField value="{!}"/>

            <!-- the condition -->
             <apex:pageBlockSectionItem >              
                 <apex:outputLabel value="Session Type"/> 
                 <apex:outputPanel > 
                     <apex:inputField value=" {!Client_Session_Record__c.Session_Type__c}">
                          <apex:actionSupport event="onchange"
                     <apex:actionStatus startText="checking..."
             <!-- end of condition -->

<!--Section 1 -->     


 <!--Section 2 -->  
 <apex:outputPanel > 
 <apex:pageBlockSection title="Initial Assessment" id="Section2"
       columns="2"  collapsible="false"
       Rendered="{if(!Client_Session_Record__c.Session_Type__c == 'Initial Assessment',true,false)}"  > 

 </apex:outputPanel >    <!--Section 2 -->  
   <!--Section 3 -->  
 <apex:pageBlockSection title="Provision" id="Section3"
 </apex:pageBlockSection>            </apex:pageBlock>  </apex:form> </apex:page>

one more question, do rich text fields not work with Rendered sections ? sometimes i get this error that rich text fields are not supported with Rendered!

share|improve this question
Can you post code from your controller? Perhaps there's something always setting it to false. If you really get stuck or if the logic starts to get complex, you might want to try abstracting the render logic in to method in the controller, e.g., public Boolean getRednerPageBlock() { //complex logic that ends with a Boolean value returned. } and then just have the rendered condition as <pageBlock rendered="{!rerenderPageBlock}'>. – Peter Knolle Dec 26 '12 at 19:59
thanks it did work when i used a public class! :) – maha Dec 27 '12 at 5:00

I'm guessing you are using a Standard Controller

Heres a simplistic reduced form of your problem, which works okay - here the second pageBlockSection is rendered when the Account Type is 'Prospect'

A few observations, while I see you are trying to reRender the pageBlock, i don't see it as part of your markup. You will need to rerender the containing element to render a component that wasn't originally rendered when the page loaded, in this case your second pageBlockSection.

Also for your rendered expression - it is enough to write rendered = "{!Client_Session_Record__c.Session_Type__c == 'Initial Assessment'}"

<apex:page standardController="Account">

<apex:pageBlock id="thePageBlock">

<apex:pageBlockSection id="pbs1" title="Basic Information" columns="2"> 

    <apex:inputField value=" {!Account.Type}">
           <apex:actionSupport event="onchange" reRender="thePageBlock" status="status"/>
            <apex:actionStatus startText="checking..." id="status"/>


<apex:pageBlockSection title="Initial Assessment" id="Section2"
       columns="2"  collapsible="false" rendered="{!Account.Type=='Prospect'}"> 

<apex:outputField value="{!Account.Name}"/>

share|improve this answer
thanks all for answering my question I did try using rendered = "{!Client_Session_Record__c.Session_Type__c == 'Initial Assessment'}" and it didn't work, that's why I went to the if statement but still didn't work... it's like the rendered condition is always false for some reason – maha Dec 26 '12 at 12:10
<apex:pageBlockSection title="Initial Assessment" id="Section2"
   columns="2"  collapsible="false"
   Rendered="{!IF(Client_Session_Record__c.Session_Type__c =='Initial Assessment','true','false')}"> 

Ensure You have Getter Setter for boolean and once its set its returned on the Page .May be reRender of the Pannel can help.

Answering your Second question there is some hack on this blog .Have a look at this

share|improve this answer
thanks all for answering my question – maha Dec 26 '12 at 12:07
<apex:page standardController="category_wise__c" extensions="rendering">
 <apex:form >
 <apex:pageBlock id="thePageblock">
 <apex:pageBlockSection columns="1">
<apex:actionSupport rendered="true" immediate="true" event="onchange" reRender="thePageblock">
 <apex:inputField value="{!category_wise__c.category__c}"/>
 <apex:actionStatus >
   <apex:inputField value="{!category_wise__c.IPD_Name__c}" rendered="{!category_wise__c.category__c=='IPD'}"/>
 <apex:inputField value="{!category_wise__c.IPD_Disease__c}" rendered="{!category_wise__c.category__c=='IPD'}"/>
 <apex:inputField value="{!category_wise__c.IPD_Details__c}" rendered="{!category_wise__c.category__c=='IPD'}"/>
 <apex:inputField value="{!category_wise__c.IPD_Phone_No__c}" rendered="{!category_wise__c.category__c=='IPD'}"/>
 <apex:inputField value="{!category_wise__c.OPD_Name__c}" rendered="{!category_wise__c.category__c=='OPD'}"/>
 <apex:inputField value="{!category_wise__c.OPD_Disease__c}" rendered="{!category_wise__c.category__c=='OPD'}"/>
 <apex:inputField value="{!category_wise__c.OPD_Details__c}" rendered="{!category_wise__c.category__c=='OPD'}"/>
 <apex:inputField value="{!category_wise__c.OPD_Phone_No__c}" rendered="{!category_wise__c.category__c=='OPD'}"/>
 <apex:commandButton value="Save" action="{!save}" rendered="{(!category_wise__c.category__c=='OPD') || (!category_wise__c.category__c=='OPD')}"/>

its the right way to use rendered

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.