0

Switching between Radio Option should show and hide Outputpanel. I got this working with following code:

     <apex:selectRadio id="benefitradioid" required="True" value="{!selectedTargetBenefit}" style="float:left;">
          <apex:selectOption itemLabel="SECOND" itemValue="secondvalue"/>
         <apex:selectOption itemLabel="THIRD" itemValue="thirdvalue"/>

         <apex:actionSupport action="{!setSpecifiedBenefitLevel}" reRender="myPanelID"/> 
</apex:selectRadio>

<apex:outputPanel id="myPanelID" rendered="{!showBenefitLevel}">
     <apex:inputText ----********************>
</apex:outputPanel>

and in Controller :

public void setSpecifiedBenefitLevel(){
   System.Debug('----'+selectedTargetBenefit);
    if(selectedTargetBenefit=='secondvalue'){
        showBenefitLevel=True'
    }
}

My debug logs doesn't show anything. What could be the issue or any changes I need to do ?

2

Found Solution !!! Following thing Worked Replace the Code

 <apex:outputPanel id="myPanelID" rendered="{!showBenefitLevel}">
              <apex:inputText ----********************>
       </apex:outputPanel>

with this one

<apex:outputPanel id="myPanelID">
    <apex:outputPanel id="myInnerPanelID" rendered="{!showBenefitLevel}">
          <apex:inputText ----********************>
   </apex:outputPanel>
</apex:outputPanel>
|improve this answer|||||
  • 1
    I believe the reason this works is that when an outputpanel is not rendered on the page, it literally doesn't exist on the page to be re-rendered. So you have to have an outer element that is rendered all the time and so will be addressable by the actionSupport. When that rerenders, the page re-evaluates the rendered= logic of everything inside it. – Jeremy Nottingham Dec 17 '14 at 15:27

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.