Visualforce(Salesforce)ページの第一人者からの助けを探しています。
背景:ドロップダウンリストがあります(Visualforceページの観点からはapex:selectList)。その選択オプションは、RemoteAction(コントローラー内)から返されたデータ(JSON形式)を使用してjQueryによって構築されます。
問題:選択したアイテムの値をコントローラーに送信するコマンドボタンをクリックすると、常にエラーメッセージ(j_id0:j_id2:j_id3:j_id4:orgList:検証エラー:値が無効です)が報告されます。
何かご意見は?どうもありがとう。
トロイ
Visualforceマークアップ:
<apex:panelGrid columns="2">
<apex:selectList id="orgList" value="{!selected}" size="1">
</apex:selectList>
<apex:commandButton value="Add" action="{!add}" style="width:80px">
</apex:panelGrid>
JavaScript:
$j("input[id$='azc']").keyup(function(){
var op = $j("select[id$=orgList]");
if($j(this).val().length >= 6){
op.empty().append('<option value=""></option>');
OrgController.findOrgs($j(this).val(), function(result, event){
if(event.status){
var data = $j.parseJSON('[' + result.replace(/'/g, '"') + ']');
$j.each(data, function(){
$j('<option />', {value: this['value'], text: this['label']}).appendTo(op);
});
}else{
alert(event.message);
}
},{escape:true});
}
OrgController
public String selected { get; set; }
public PageReference add(){
Customer__c customer = findSelected(selected);
if(customer != null){
customer.Pending__c = 'Yes';
update customer;
}
return null;
}