+ Start a Discussion
Saad Ahmad 27Saad Ahmad 27 

How to retain a selected value of a drop down pick list in home page narrow component after page refresh?

I have a visualforce page and would like retain the picklist value that the user selects on page reload. It's set to "Internal" by default, however, if the user chooses "External", this should now be the default on page reload. Thank you all for your advise!

<apex:page controller="ExternalReportsController" action="{!getReports}" showChat="false" sidebar="false" showHeader="false">
    <style>body { background-color: inherit !important; }</style>
    <apex:form id="theForm">
        <apex:outputLabel value="<b>Network: </b>" escape="false"/>
        <apex:selectList value="{!selectedNetwork}" multiselect="false" size="1">
            <apex:selectOption itemLabel="Internal" itemValue="Internal"/>
            <apex:selectOption itemLabel="External" itemValue="External"/>
            <apex:actionSupport event="onchange" action="{!getReports}" reRender="theForm"/>
        <apex:repeat value="{!reports}" var="r" id="reportList">
            <a href="{!IF(selectedNetwork = 'External', r.External_Server__c, r.Internal_Server__c) + r.Link__c}{!IF(r.Add_Territory__c, territories, null)}" target="_blank">{!r.Name}</a><br/>
            <apex:variable value="{!0}" var="temp" rendered="{!r.Line_Break__c}"><br/></apex:variable>
Store the default value as a custom setting record and use it on page load. On select of picklist value, fetch the custom setting record and update it with new default value.
Saad Ahmad 27Saad Ahmad 27
Thanks Shalabh. I will give this a try.