长期以来,我一直需要您的帮助:
问题: 我创建了如下的自定义选择列表,当页面刷新时,选择列表的值也被刷新。我要保留它。请让我知道我在哪里做错了。
在此方面,任何帮助将不胜感激。谢谢
*****************
Visualforce Page:
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:selectList value="{!SelectLanguage}" multiselect="false" size="1">
<apex:selectOptions value="{!LanguageOptions}" />
<apex:actionSupport event="onchange" action="{!Refresh}"/>
</apex:selectList>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
Controller:
//Controller to create and add picklist value
public String SelectLanguage{get;set;}
public String LanguageOption{get;set;}
public List<SelectOption> getLanguageOptions()
{
List<SelectOption> LanguageOption= new List<SelectOption>();
LanguageOption.add(new SelectOption(',','Language'));
LanguageOption.add(new SelectOption('Es_US','English'));
LanguageOption.add(new SelectOption('Da','Danish'));
LanguageOption.add(new SelectOption('nl_NL','Dutch'));
LanguageOption.add(new SelectOption('zh_TW','Chinese (Traditional)'));
return LanguageOption;
}
// Page refresh with additional language parameter
public pagereference Refresh() {
string langcode = SelectLanguage;
pagereference pg=new pagereference('/supportagent/supportAgentPage?lang=es_US');
pg.getParameters().put('lang',SelectLanguage);
pg.setRedirect(true);
return pg;
}