I have two fields in my SalesForce page.

  1. Site Field (newReq.Site__c)
  2. Requisition (newReq.Requisition_Type__c)

Based on my Requisition type, I want my site field to be visible and hidden. Here are the conditions on when the site field should be seen and when not.

Condition 1: When the user selects Requisition Type: "XYZ" I want site field to be hidden.

Condition 2: When the user selects anything other than XYZ then I want to show the site field again.

My 1st question: Now I am confused here. As in, what to use when. My Requsition field should be declared as reRender (code 1) or as rendered (code 2).

Secondly, So when I use reRender in my VisualForce page, do I need to add any code in my Controller ?

This is the code which I am trying to use:

Code 1

<apex:inputField id="reqType" styleClass="reqLineType" html-class="requist" 
<apex:actionSupport event="onchange" reRender="siteMaterial"/>

Code 2

<apex:outputPanel id="thePanelWrapper">
<apex:outputPanel rendered="{!bRenderThePanel}">
<apex:inputField value="{!newReq.Site__c}"  id="siteName" html-class="hideSite"/> 

1 Answer 1


As an alternative, you can avoid the action= attribute on the apex:actionSupport as well as the action method and code your controller property as follows:

public Boolean getBRenderThePanel() {return newReq.requisition_type__c != 'XYZ';}

Note that although the VF page refers to

<apex:outputPanel rendered="{!bRenderThePanel}">

this resolves itself to the method getBRenderThePanel at compile time

When action is not included on actionSupport, the page will simply refresh after any changed values are sent to the controller. Hence, since the value of newReq.requisition_type__c is sent to the controller by actionSupport, when the page refreshes, the request to getBRenderThePanel is made which has the current value of requisition_type__c so it can return the proper true/false value.

  • or public Boolean getbRenderThePanel() { return newReq.requisition_type__c != 'XYZ'; }; the setter really isn't necessary, since it will never be used.
    – sfdcfox
    Nov 1, 2014 at 0:43
  • you are of course, correct -- I fixed my answer - I had blindly copied my usual pattern for VF controller properties which was overkill in this use case
    – cropredy
    Nov 1, 2014 at 16:10
  • What you have doesn't work. I don't get why @sfdcfox wouldn't just answer the question, since he seems to have to best solution. You either need to make it a getter, or change the property to a function like fox suggested.
    – NSjonas
    Nov 4, 2014 at 0:57
  • yikes - I didn't fix up the code correctly - missing the (). Thanks; now changed
    – cropredy
    Nov 4, 2014 at 1:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .