I've overridden the new Opportunity page and I have a dynamically generated picklist of Contact Names and a static value "New Contact". When "New Contact" is selected a new panel is displayed with input fields (required) to create a new Contact. The rerendering of the Contact panel works fine.

My issue is if this value is selected by accident and the user means to pick another value the page won't allow them to due to the required fields in the newly displayed Contact panel. Is it possible to unrender (!) the panel on going from "New Contact" to "Another Value"?

Select List:

<apex:selectList value="{!SelectedCon}" size="1" label="Select Contact">
     <apex:selectOptions value="{!con}"/>
           <apex:actionSupport event="onchange" reRender="conContainer,debugContainer"/>

Dynamic Panel:

    <apex:outputPanel id="conContainer">
        <apex:outputPanel id="con" rendered="{!If(SelectedCon='New Contact',true,false)}">
            <apex:pageBlockSection title="New Contact Information" collapsible="false">
            <apex:inputField value="{!constring.FirstName}" required="true"/>
            <apex:inputField value="{!constring.LastName}" required="true"/>          
            <apex:inputField value="{!constring.Email}" required="true"/> 
            <apex:inputField value="{!constring.Title}" required="true"/>
  • 1
    Side note: {!SelectedCon='New Contact'} returns true or false. There's no reason for an IF here (it bloats the view state size and slows rendering).
    – sfdcfox
    Oct 23, 2014 at 16:29

1 Answer 1


You can sometimes get away with using immediate="true" on the action element that triggers the reRender (in this case, apex:actionSupport), which suspends Visualforce validations, but usually also has a nasty side effect of skipping controller logic.

A better way to handle the scenario is to use an apex:actionRegion that surrounds the apex:actionSupport. This isolates the action from validations that would occur elsewhere on the page. It can be tricky to get an apex:actionRegion to work the way you want it to, but the isolation means that validations only run on fields inside the region. You'll want to use renderRegionOnly="false" to allow the changes to propagate outside the region so that your other section will "unrender."

  • I thought it might have to be actionsupport but I had it can cause difficulties. I'll have a go with that, thanks.
    – Girbot
    Oct 23, 2014 at 19:47
  • perfect sorted it now, thanks for your help. Took some fiddling with as it removed the field label. So for others who also hit this I needed to put the apex:actionRegion in a <apex:pageBlockSectionItem> and use a <apex:outputLabel value="Select Contact" for="conList"/>
    – Girbot
    Oct 31, 2014 at 11:26

You must log in to answer this question.

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