function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Anirban RoyAnirban Roy 

Error: Formula Expression is required on the action attributes, in VF to Controller Class call

Dear Friends,

I am facing some newbie jerks while trying to call a controller froma  VF Page.

This is the error which I tried to debug a lot from Developer forums, but not of much help:

Error is: Formula Expression is required on the action attributes.

My VF Page:

<apex:page controller="BankDetailsController">
     <apex:form >
   <apex:pageBlock >
      <apex:commandButton value="BANK" action="{!getbankDet}"/>
         <apex:pageBlockSection>
             Following are the Bank Details
                   {!Response}    
       </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
</apex:page>

My Controller: calls a web service which I imported as a Apex class in my org <basically its a web service written in another salesforce org of mine>

public class BankDetailsController {
    
    //public string bank { get { return getbankDet(); } }
    public String Response {get; set;}
    public string getbankDet() 
    {

        string accname = 'GoGlobalStrategies';
        partnerSoapSforceCom.Soap myPartnerSoap = new partnerSoapSforceCom.Soap(); 
        partnerSoapSforceCom.LoginResult partnerLoginResult = myPartnerSoap.login('somnath.paul4@cognizant.com', 'MyPasswordgPeEzXp6zqiICng3M8wKQtqd');
        soapSforceComSchemasClassGetbankdet.SessionHeader_element webserviceSessionHeader=new soapSforceComSchemasClassGetbankdet.SessionHeader_element();
        webserviceSessionHeader.sessionId = partnerLoginResult.sessionId;
        soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount getBankdet=new soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount();
        getBankdet.SessionHeader=webserviceSessionHeader;
        Response = getBankdet.getBankDetails(accname);
        return Response;
 }
}

When I click on the BANK button in my VF Page, the response should flow in, but actually the error flows out :(

Can anyone tell me where am I going wrong here?
 
Best Answer chosen by Anirban Roy
Abhishek BansalAbhishek Bansal
Hi ,

Please change you controller class from below mentioned code :
 
public class BankDetailsController {
    
    //public string bank { get { return getbankDet(); } }
    public String Response {get; set;}
    public PageReference getbankDet() 
    {

        string accname = 'GoGlobalStrategies';
        partnerSoapSforceCom.Soap myPartnerSoap = new partnerSoapSforceCom.Soap(); 
        partnerSoapSforceCom.LoginResult partnerLoginResult = myPartnerSoap.login('somnath.paul4@cognizant.com', 'MyPasswordgPeEzXp6zqiICng3M8wKQtqd');
        soapSforceComSchemasClassGetbankdet.SessionHeader_element webserviceSessionHeader=new soapSforceComSchemasClassGetbankdet.SessionHeader_element();
        webserviceSessionHeader.sessionId = partnerLoginResult.sessionId;
        soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount getBankdet=new soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount();
        getBankdet.SessionHeader=webserviceSessionHeader;
        Response = getBankdet.getBankDetails(accname);
        return null;
 }
}
When we call any function from our VF page than we use have to use PageReference return type for our methods.
Let me know if you need more help.

Regards,
Abhishek
 

All Answers

Gaurav_SrivastavaGaurav_Srivastava
Hi,

In VF page, button set to call action method "getbankDet" and this action method in controller class "getbankDet" has return type String. Action method in controller should have return type either void or PegeReference.

Change the return type of method "getbankDet" as void and run your code.

Thanks,
Gaurav



 
Abhishek BansalAbhishek Bansal
Hi ,

Please change you controller class from below mentioned code :
 
public class BankDetailsController {
    
    //public string bank { get { return getbankDet(); } }
    public String Response {get; set;}
    public PageReference getbankDet() 
    {

        string accname = 'GoGlobalStrategies';
        partnerSoapSforceCom.Soap myPartnerSoap = new partnerSoapSforceCom.Soap(); 
        partnerSoapSforceCom.LoginResult partnerLoginResult = myPartnerSoap.login('somnath.paul4@cognizant.com', 'MyPasswordgPeEzXp6zqiICng3M8wKQtqd');
        soapSforceComSchemasClassGetbankdet.SessionHeader_element webserviceSessionHeader=new soapSforceComSchemasClassGetbankdet.SessionHeader_element();
        webserviceSessionHeader.sessionId = partnerLoginResult.sessionId;
        soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount getBankdet=new soapSforceComSchemasClassGetbankdet.GetBankDetailsofAccount();
        getBankdet.SessionHeader=webserviceSessionHeader;
        Response = getBankdet.getBankDetails(accname);
        return null;
 }
}
When we call any function from our VF page than we use have to use PageReference return type for our methods.
Let me know if you need more help.

Regards,
Abhishek
 
This was selected as the best answer
Anirban RoyAnirban Roy
Abhishek, that was a brilliant help and in so less time. Thanks again.

It worked fine! Salesforce is such a brilliant product because of guys like you !