0

我一直在尝试从我的 visualforce 页面调用扩展方法。

<apex:page title="Title" standardController="Account" showChat="true" tabStyle="Account" standardStylesheets="true"  showHeader="true" extensions="AccountExtension">

<script type="text/javascript">
Sfdc.onReady(function() {
        if({!isTrue}){
            // Do Something
        }
});
</script>

我的扩展中的方法:

public with sharing class AccountExtension {
    public boolean isTrue(){
        return true;
    }
}

当我尝试保存它时,我收到消息:错误:未知属性 'AccountStandardController.isTrue'

任何的想法?

4

2 回答 2

3

Lex 在评论中提到的第一个选项是将方法重命名为getIsTrue()- 这将是 property 的 getter isTrue,这将为您提供底层支持。

另一种选择是以下列方式创建顶点属性:

 public with sharing class AccountExtension {

     public AccountExtension(ApexPages.StandardController controller) {
     }

     public Boolean isTrue {
         get{
             isTrue = false;
             //implement logic
             return isTrue;
         }
         set{}
     }
 }
于 2013-07-12T19:55:35.637 回答
0

将 public boolean isTrue(){ 更改为 public boolean getisTrue(){

于 2013-07-17T13:51:32.410 回答