0

我有多选选项列表,我想获取插入和更新操作的选定值。

<apex:page standardController="Change_Request__c" sidebar="false" extensions="Change_RequestController"> 
  <apex:selectList label="Select Pasenger(s)" value="{!Change_Request__c.Passenger_Name__c}" multiselect="true" onfocus="getSelectedID('{!$Component.empid}');" >
      <apex:selectOptions value="{!pax}" />
  </apex:selectList>

这是我的扩展:

public class Change_RequestController {
  private final Change_Request__c changer;
  public List<selectOption> pax;
  public Change_RequestController(ApexPages.StandardController controller) {
    this.changer = (Change_Request__c)controller.getRecord();
  }
  public List<selectOption> getPax() {
    List<selectOption> options = new List<selectOption>();
    String fullName;
    for (Passenger_Info__c p : [SELECT Id,First_Name__c,Name  from Passenger_Info__c ]) {
      fullName = (p.First_Name__c == null)?'':p.First_Name__c+' '+p.Name; 
      options.add(new selectOption(fullName, fullName));
     }
     return options;
  }
  public List<selectOption> setPax() {
    List<selectOption> options = new List<selectOption>();
    for (String pa : changer.Passenger_Name__c.split(',') ) {
      options.add(new selectOption(pa, pa));
     }
     return options;
  }
}
4

1 回答 1

0

将控制器更改为

public class Change_RequestController {
  public Change_Request__c changer{get;set;}
  public Change_RequestController(ApexPages.StandardController controller) {
    this.changer = (Change_Request__c)controller.getRecord();
  }
  public List<selectOption> getPax() {
    List<selectOption> options = new List<selectOption>();
    String fullName;
    for (Passenger_Info__c p : [SELECT Id,First_Name__c,Name  from Passenger_Info__c ]) {
      fullName = (p.First_Name__c == null)?'':p.First_Name__c+' '+p.Name; 
      options.add(new selectOption(fullName, fullName));
     }
     return options;
  }
}

和页面

<apex:selectList label="Select Pasenger(s)" value="{!changer.Passenger_Name__c}" multiselect="true" onfocus="getSelectedID('{!$Component.empid}');" >
      <apex:selectOptions value="{!pax}" />
  </apex:selectList>
于 2013-06-06T05:32:54.957 回答