2014-01-25 37 views
0

我创造我visualforce页面复选框列表如下Salesforce/Visualforce:apex:selectCheckboxes将默认设置为选中状态?

 <apex:selectCheckboxes value="{productItems}" layout="pageDirection"> 
      <apex:selectOptions value="{!items}"/><br/> 
     </apex:selectCheckboxes> 

我的项目和productItems也同样设置为例子https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_selectOption.htm

在哪里或如何,我可以把我的值有一个缺省真实的?我不在Visualforce组件顶点中设置海:selectOptions或apex:selectCheckboxes。

任何帮助,将不胜感激。

回答

1

在控制器中初始化您的productItems,例如在构造函数中。

List<String> productItems = new List<String>(); // boring 

List<String> productItems = new List<String>{'foo', 'bar', 'baz'}; // will have 
// these 3 checked assuming there are SelectOptions available with exactly same 
// values. 

想想那样。理想情况下,控制器类应该自行开发。也许重用并从另一个类调用,没有任何Visualforce上下文。所以在纯粹的顶点,你只需要初始化列表;)

+0

太好了,谢谢你的帮助! – SalesforceQueries

相关问题