Skip to main content Join the Agentforce Virtual Hackathon to build innovative solutions and compete for a $50k Grand Prize. Sign up now. Terms apply.
Hi All,

I was doing some poc for my work and I encountered with a weird problem. On the selection of radio button value I want to rerender the output panel below (based upon the selected radio button value) but it is not functioning well.

I know I'm doing some silly mistake but not able to recognize. Here is my code :-

VF Page

------------------------------------------------------------------------

<apex:page Controller="TestPage_Class">

<apex:form >

<apex:selectRadio id="selectedContact" value="{!selectedValue}">

<apex:selectOptions value="{!listSelectedContact}"/>

<apex:actionSupport event="onchange" reRender=" outerOutputP1, outerOutputP2" status="status" action="{!selectOnClick}"/>

</apex:selectRadio>

<apex:actionstatus id="status">

<apex:facet name="start">

<div class="waitingSearchDiv" id="el_loading" style="background-color: ⌗fbfbfb;

height: 100%;opacity:0.65;width:100%;">

<div class="waitingHolder" style="top: 74.2px; width: 91px;">

<img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />

<span class="waitingDescription">Please Wait...</span>

</div>

</div>

</apex:facet>

</apex:actionstatus>

<apex:outputPanel id="outerOutputP1">

<apex:outputPanel id="innerOutputP1" rendered="{!op1}">

<apex:outputLabel > Output Panel 1</apex:outputLabel>

</apex:outputPanel>

</apex:outputPanel>

<apex:outputPanel id="outerOutputP2">

<apex:outputPanel id="innerOutputP2" rendered="{!op2}">

<apex:outputLabel > Output Panel 2</apex:outputLabel>

</apex:outputPanel>

</apex:outputPanel>

</apex:form>

</apex:page>

Controller Class :-

------------------------------------------------------------------------------------------

public class TestPage_Class {

public String selectedValue {get; set;}

public Boolean op1 {get; set;}

public Boolean op2 {get; set;}

public List<SelectOption> getlistSelectedContact() {

List<SelectOption> options = new List<SelectOption>();

options.add(new SelectOption('Value1','Output Panel 1'));

options.add(new SelectOption('Value1','Output Panel 2'));

return options;

}

public PageReference selectOnClick() {

if(selectedValue=='Value1') {

op1 = true;

op2 = false;

} else {

op1 = false;

op2 = true;

}

return null;

}

}

Please try to understand this code and provide me a solution.

Thanks in advance.
3 answers
  1. Feb 18, 2017, 7:26 AM
    Hi Kiruba!

    I got it working now. Here is the working code :-

     

    <apex:page Controller="TestPage_Class">

    <apex:form id="myForm">

    <apex:pageBlock id="mainPB">

    <apex:actionregion>

    <apex:selectRadio value="{!selectedValue}" rendered="true">

    <apex:selectOptions value="{!listSelectedContact}"/>

    <apex:actionSupport event="onchange" reRender="outerOutputPanel, op1, op2" action="{!selectOnClick}"/>

    </apex:selectRadio>

    <apex:outputPanel id="outerOutputPanel" layout="block">

    <apex:outputPanel id="op1" layout="block" rendered="{!IF(selectedValue=='Value1',true,false)}">

    <apex:outputLabel > Output Panel 1 </apex:outputLabel>

    </apex:outputPanel>

    <apex:outputPanel id="op2" layout="block" rendered="{!IF(selectedValue=='Value2',true,false)}">

    <apex:outputLabel > Output Panel 2 </apex:outputLabel>

    </apex:outputPanel>

    </apex:outputPanel>

    </apex:actionregion>

    </apex:pageBlock>

    </apex:form>

    </apex:page>

    actionRegion should be placed. Hope it helps many of developers.

    Cheers :)
Loading
0/9000