Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

How to call an apex method in If block in visualforce .my page segment is

<apex:outputText  value="{!IF (IsFbConnected,'Facebook is Connected','Facebook is not Connected')}" />

and my apex method in controller is

 public Boolean IsFbConnected(){
  return false;
  }

and its giving me error while saving:Unknown Property MyController.IsFbConnected.please tell the right way to call an apex method .is it possible or not ??

share|improve this question

2 Answers 2

Yes, this is possible. Currently it's not accessible by the salesforce getter logic to the VF page. You'll have to make your method called to get your boolean value as such getIsFbConnected. Below is how it will look like:

public Boolean getIsFbConnected(){
    return false;
}

Your VF page can stay the same.

As @GreenStork said:

Your property needs a getter to be accessible to your page. Here is alternative syntax: public Boolean isFbConnected { get; private set; }

share|improve this answer
1  
Your property needs a getter to be accessible to your page. Here is alternative syntax: public Boolean isFbConnected { get; private set; } –  greenstork Mar 4 at 17:03
    
To recap: all variable getters must be prefixed with 'get', so your method name should be called "getIsFbConnected()" but you'll reference it on your VF page by "{!isFbConnected}" –  amatorVitae Mar 4 at 18:13

Instead you can use this approach:

class MyClass
{
   // Define a boolean property
   public Boolean isFbConnected {get; set;}

   public MyClass()
   { 
      isFbConnected = IsFbConnected();
   }

   public Boolean IsFbConnected()
   {
      return false;
   }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.