0

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
        </div>
        <table border="" style="width:100%;" >
            <tr>    
               <td valign="middle" align="right" style="width:21%; padding-right: 3px;" >
                    <apex:outputLabel value="Type of Change:"/>                                
                </td>
                <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:selectList>                      
                </td>
            </tr>
        </table>    
    </div>
</apex:outputPanel>            

<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.

3

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}"/>
                    </apex:selectList> 

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 – Our Man in Bananas Jan 12 '16 at 12:02
  • yes try to rerender that – Tushar Sharma Jan 12 '16 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 – Our Man in Bananas Jan 12 '16 at 12:08
  • <apex:actionSupport event="onchange" rerender="PageFields ,RecordTypeBlank" and rerender the parent component of RecordTypeBlank field – Tushar Sharma Jan 12 '16 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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