0
我試圖模仿salesforce鉛轉換過程。我有一個visualforce頁面和一個控制器。我遇到的問題是當頁面加載下拉列表時是空白的。我的目標是擁有一個字符串列表並用這個列表填充下拉列表。我搜索了高和低,並不知道爲什麼下拉是空白的。這裏是我的代碼,任何幫助表示讚賞。在字符串列表中填充Visualforce頁面中的下拉列表
--controller--
public with sharing class LeadConvertController {
public Lead l {get; private set;}
public Account a {get; private set;}
public list<SelectOption> options {get; set;}
public String attachToclient {get; set;}
public LeadConvertController(ApexPages.StandardController sc) {
for (Lead referral : [SELECT Id, Name, Phone, OwnerId
FROM Lead
WHERE Id = : sc.getId()]) {
l = referral;
}
if (l == null) {
system.debug(logginglevel.error, 'Missing lead');
}
//query by name and phone to find possible Existing Accounts or contact
options = findExistingClients(l);
}
public list<SelectOption> findExistingClients (Lead leadToacc) {
list<SelectOption> findClients = new list<SelectOption>();
for (Account acc : [SELECT Id, Name, Type, Primary_Contact__c FROM Account WHERE Name = :leadToacc.Name OR Phone = :leadToacc.Phone]) {
findClients.add(new SelectOption(acc.Id, 'Attach to Existing: ' + acc.Name));
a = acc;
}
for (Contact c : [SELECT Id, Name FROM Contact WHERE Name = :leadToacc.Name OR Phone = : leadToacc.Phone]) {
findClients.add(new SelectOption(c.Id, 'Attach to Existing: ' + c.Name));
}
findClients.add(new SelectOption(l.Name, 'Create new Client/Prospect: ' + l.Name));
return findClients;
}
}
--visualforce page--
<apex:page title="Lead Convert" standardController="Lead" tabStyle="Lead" extensions="LeadConvertController">
<apex:sectionHeader title="Convert Referral" subtitle="{!l.Name}">
<apex:outputPanel id="main" rendered="true">
<apex:form>
<apex:pageBlock>
<apex:pageBlockButtons>
<apex:commandButton action="{!convert}" id="Convert" value="Convert" />
<apex:commandButton action="{!cancel}" id="Cancel" value="Cancel" />
</apex:pageBlockButtons>
<apex:pageBlockSection title="Convert Referral" collapsible="false" columns="1">
<apex:inputField label="Record Owner" value="{!l.OwnerId}" required="true" />
<apex:pageBlockSectionItem>
<apex:outputPanel>
<apex:outputLabel value="Client/Prospect Name" />
<apex:selectlist value="{!attachToclient}" required="true" />
<apex:selectOptions value="{!options}" />
<apex:outputlink title="View" value="{!a.Primary_Contact__c}">View</apex:outputlink>
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:outputPanel>
</apex:sectionHeader>
</apex:page>
是完美的工作,謝謝! – Hardy