Salesforce 加载时在可视强制页面上选择选取列表选项

Salesforce 加载时在可视强制页面上选择选取列表选项,salesforce,visualforce,pageload,picklist,Salesforce,Visualforce,Pageload,Picklist,我有一个visualforce页面,其中有一个名为Topic的选择列表,有时我需要在页面加载时选择其中一个选择列表选项(这意味着主题将从另一个页面传递,并且需要在第一次加载页面时选择)。我不知道该怎么做?我正在发布Visualforce页面的一部分,该页面处理主题选择和下面的控制器代码。任何帮助都将不胜感激。谢谢 视觉力页面: <!---------------------------------- Select Topic --------------------------------

我有一个visualforce页面,其中有一个名为Topic的选择列表,有时我需要在页面加载时选择其中一个选择列表选项(这意味着主题将从另一个页面传递,并且需要在第一次加载页面时选择)。我不知道该怎么做?我正在发布Visualforce页面的一部分,该页面处理主题选择和下面的控制器代码。任何帮助都将不胜感激。谢谢

视觉力页面:

<!---------------------------------- Select Topic ----------------------------------------------------->    
                    <apex:pageblockSection title="Select the Topic" >     
                            <apex:selectList value="{!topic}" size="1">
                                <apex:outputlabel for="Topic" value="Pick a Topic :" ></apex:outputlabel> &nbsp;&nbsp;&nbsp;
                                <apex:selectOptions id="topic" value="{!Topics}"/>
                                    <apex:actionSupport action="{!populateParameters}"  reRender="parametersSection,querySection" event="onchange"/> 
                            </apex:selectList>
                    </apex:pageblockSection>
            <!---------------------------------- End of Select Topic ---------------------------->

            <!---------------------------------- Parameters for Topic ----------------------------------------------------->    
                 <apex:pageblockSection id="parametersSection" title="Input Parameters"> 
                    <apex:repeat value="{!topicpParamWrapperList}" var="params">
                        <apex:outputPanel >
                            <apex:outputlabel value="{!params.parameter.Name}" ></apex:outputlabel> &nbsp;&nbsp;&nbsp; 
                            <apex:inputfield value="{!params.parameter.inputValue__c}" rendered="{!params.renderAsText}"> 
                                <apex:actionsupport action="{!placeValuesInQuery}" reRender="querySection,splunUrlLink" event="onchange"/>
                            </apex:inputfield> 
                            <apex:inputfield value="{!params.parameter.DateTimeValueHolder__c}" rendered="{!params.renderAsDate}">
                                <apex:actionsupport action="{!placeValuesInQuery}" reRender="querySection,splunUrlLink" event="onchange"/>
                            </apex:inputfield>
                        </apex:outputPanel>
                    </apex:repeat>
                 </apex:pageblockSection>
            <!---------------------------------- End of Parameters for Topic ----------------------------------------------------->    

Apex控制器

public List < topicpParamWrapper > topicpParamWrapperList {
      get;
      set;
   } {
      topicpParamWrapperList = new List < topicpParamWrapper >();
   }


public void populateParameters() 
{
        if(!topicpParamWrapperList.isEmpty())
        {
                topicpParamWrapperList.clear();
        }

        if(topic!='' && topic!=Null)
        {
                for(Query_Parameter__c qParam :[select id, Parameters__r.Variable_Name__c, Parameters__r.Type__c,Parameters__r.Name  from Query_Parameter__c where Topics__c=:topic])
                {
                        Parameters__c param = new Parameters__c();
                        param.Name =qParam.Parameters__r.Name ;
                        param.type__c = qParam.Parameters__r.type__c;
                        param.Variable_Name__c=qParam.Parameters__r.Variable_Name__c;
                        topicpParamWrapperList.add(new topicpParamWrapper(param));
                }
                getQueryToRun();
        }

}

public void getqueryToRun(){

        if(mapTopics.containsKey(topic))
        {
                this.queryToRun =mapTopics.get(topic).query__c;
                this.queryMain=mapTopics.get(topic).query__c;
        }

} 

 public List < topicpParamWrapper > paramList {
      get;
      set;
   } {
      paramList = new List <topicpParamWrapper>();
   }
public ListtopicpParamWrapper列表{
收到
设置
} {
topicpParamWrapperList=新列表();
}
public void populateParameters()
{
如果(!topicpParamWrapperList.isEmpty())
{
topicpParamWrapperList.clear();
}
if(主题!=''&&topic!=Null)
{
对于(查询参数c qParam:[从查询参数c中选择id、参数变量名称、参数类型、参数名称,其中主题c=:主题])
{
Parameters__cparam=新参数__c();
param.Name=qParam.Parameters\uuuu r.Name;
param.type__c=qParam.Parameters__r.type__c;
param.Variable\u Name\u c=qParam.Parameters\u r.Variable\u Name\u c;
添加(新的topicpParamWrapper(param));
}
getQueryToRun();
}
}
public void getqueryToRun(){
if(mapTopics.containsKey(主题))
{
this.queryToRun=mapTopics.get(topic).query\c;
this.queryMain=mapTopics.get(topic).query\c;
}
} 
公共列表paramList{
收到
设置
} {
paramList=新列表();
}

您真正需要做的就是将
主题设置为构造函数中的某个初始值(名称与类名称相同的特殊函数)。您将其设置为某个值,然后它将在visualforce中正确渲染(假设相同的值是可选选项之一!)

您省略了构造函数或

如果您的主题有包含&、空格等内容的风险,您可能应该在构建链接时使用它

/apex/MyPage?topic=Something, something
topic = ApexPages.currentPage().getParameters().get('topic');