Rerender based on what's selected in Apex #inSalesforce

Rerender based on what's selected in Apex #inSalesforce


Page:


<apex:page controller="renderSampleClass" id="thePage">
    <apex:form >           
       <apex:selectList id="selected_list" value="{!val}" required="false" size="1">
            <apex:selectOption itemvalue="None" itemLabel="–None–"/>
            <apex:selectOption itemvalue="Hello" itemLabel="Hello"/>
            <apex:selectOption itemvalue="World" itemLabel="World"/>
<apex:selectOption itemvalue="Repeat" itemLabel="Repeat"/>
            <apex:actionSupport event="onchange" reRender="Details" action="{!UpdateMethod}"/>
        </apex:selectList>
        <br/>
        <apex:panelGroup >       
            <apex:outputPanel id="Details">           
                The value based on select list value: {!someVal}           
            </apex:outputPanel>
        </apex:panelGroup>
    </apex:form>
</apex:page>



Class:


public class renderSampleClass{
    public String val {get; set;}
    public String someVal {get; set;}
    public renderSampleClass(){}
    public void UpdateMethod(){
        if(val == 'Hello'){
            someVal = 'Hello';
        }
        else if(val == 'World'){
            someVal = 'World';
        }
else if(val == 'Repeat'){
            someVal = 'Repeat';
        }
        else{
           someVal = 'Select a value';
        }
    }           
}




Comments