On selecting Yes/No from the selectRadio options, outputPanel reRender is not working
Here's the code
I have 2 radio buttons.. yes/no. If user clicks Yes, it should display the outputPanel. If No, the outputpanel should hide. Its simple. But Im missing something. Here's my code.
<apex:selectRadio id="selectedAPTransport" value="{!selectedAPTransport}">
<apex:selectOptions value="{!ListAPTransport}"/>
<apex:actionSupport event="onchange" reRender="Travel_block" />
</apex:selectRadio>
<apex:outputPanel id="Travel_block" rendered="{!IF(selectedAPTransport == 'Yes',true,false)}" >
<apex:repeat id="TravelNeeded" value="{!map}" var="item" >
<!-- columns -->
</apex:repeat>
</apex:outputPanel>
Apex class
public String selectedAPTransport {get; set;}
public List<SelectOption> getListAPTransport() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('Yes','Yes'));
options.add(new SelectOption('No','No'));
return options;
}
public String getselectedAPTransport() {
return selectedAPTransport;
}
public void setselectedAPTransport(String selectedAPTransport) {
this.selectedAPTransport = selectedAPTransport;
}
Best Answer
Your
apex:outputPanel
withid="Travel_block"
is not rendered by default, because theselectedAPTransport
variable is notYes
. If it is not rendered, then it is not accessible by ID foractionSupport
. You need to wrap this pannel with another panel without layout and rerender it (wrapperPannel
in my example):