首页 > 解决方案 > 如何在visualforce的顶点命令按钮中调用参数化控制器?

问题描述

我有以下类型的顶点类

public standardcontroller(){

List<account> accountList = [SELECT Name FROM Account LIMIT 20];
ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(accountList);
List<Account> selected=ssc.getSelected();
}


public PageReference save(List<Account> selected){
 if(code logic)
}

视觉力页面包含一个命令按钮

<apex:commandButton action="{!save}" value="Save" id="theButton"/>

从vf页面调用save方法时如何传递选择的参数列表

标签: salesforceapexvisualforce

解决方案


您必须检索该记录的 ID(如果是详细信息按钮)

Id recordId = standardController.getId();
Account record = (Account) standardController.getRecord();
PageReference pdfPage = new PageReference('/apex/YOURVFPAGENAME');
pdfPage.getParameters().put('id',recorded); 

现在您有了该记录的 ID,现在您可以根据该 ID 在控制器中执行任何操作。


推荐阅读