I have a selectList in my VF page which allows the user to select the record type. On change the appropriate fields are shown to the user by re-rendering the PageFields.

But as well as re-rendering the Pagefields outputPanel I'd like to disable the selectList control (or even replace it with an outputField or label.

<apex:outputPanel id="RecordTypeBlank" rendered="{!recordType == ''}" >
    <div Id="RecordTypeQuestion">
        <div style="font-weight: bold;">
            Please select the record type before continuing
        <table border="" style="width:100%;" >
               <td valign="middle" align="right" style="width:21%; padding-right: 3px;" >
                    <apex:outputLabel value="Type of Change:"/>                                
                <td valign="middle" align="left" style="width:79%; padding-left: 4px;" >
                    <apex:selectList value="{!recordType}" size="1">
                        <apex:actionSupport event="onchange" rerender="PageFields" status="vfStatus"/>
                        <apex:selectOptions value="{!RecordTypes}"/>

<apex:outputpanel id="PageFields" >

I tried changing the onchange event of the selectList as below:

<apex:actionSupport event="onchange" rerender="PageFields RecordTypeBlank" status="vfStatus"/>

but that hasn't worked.

So how could I either disable the selectList, or dynamically replace it with an outputField showing the selected recordType (which is stored in the variable !recordType in my controller.

1 Answer 1


You can try one thing. Check if recordType not null then then hide this field

<apex:outputText value="{!recordType}" rendered="{!recordType != null || recordType != ''}"/ > 

<apex:selectList value="{!recordType}" size="1" rendered="{!recordType == null || recordType == ''}"">
                        <apex:actionSupport event="onchange" rerender="PageFields" status="vfStatus"/>
                        <apex:selectOptions value="{!RecordTypes}"/>

use this sample code. It will solve your problem.

  • Thanks but this doesn't replace the selectList with the outputText, possibly because the RecordTypeBlank block is not re-rendered Jan 12, 2016 at 12:02
  • yes try to rerender that Jan 12, 2016 at 12:06
  • if I try to add it as <apex:actionSupport event="onchange" rerender="PageFields RecordTypeBlank" none of the data entry fields are rendered on the change event Jan 12, 2016 at 12:08
  • <apex:actionSupport event="onchange" rerender="PageFields ,RecordTypeBlank" and rerender the parent component of RecordTypeBlank field Jan 12, 2016 at 12:22

You must log in to answer this question.

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