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
Adelchi PelizzoAdelchi Pelizzo 

Visualforce Error Formula Expression is required on the action attributes.

Hi,

I am getting the above error after cllicking on the (C2F) button. The debug logs are showing "successful" callout to webservice.


Apex Class from WSDL
 
//Generated by wsdl2apex

public class TmpCnv {
    public class FahrenheitToCelsiusResponse_element {
        public String FahrenheitToCelsiusResult;
        private String[] FahrenheitToCelsiusResult_type_info = new String[]{'FahrenheitToCelsiusResult','http://www.w3schools.com/webservices/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.w3schools.com/webservices/','true','false'};
        private String[] field_order_type_info = new String[]{'FahrenheitToCelsiusResult'};
    }
    public class CelsiusToFahrenheitResponse_element {
        public String CelsiusToFahrenheitResult;
        private String[] CelsiusToFahrenheitResult_type_info = new String[]{'CelsiusToFahrenheitResult','http://www.w3schools.com/webservices/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.w3schools.com/webservices/','true','false'};
        private String[] field_order_type_info = new String[]{'CelsiusToFahrenheitResult'};
    }
    public class FahrenheitToCelsius_element {
        public String Fahrenheit;
        private String[] Fahrenheit_type_info = new String[]{'Fahrenheit','http://www.w3schools.com/webservices/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.w3schools.com/webservices/','true','false'};
        private String[] field_order_type_info = new String[]{'Fahrenheit'};
    }
    public class CelsiusToFahrenheit_element {
        public String Celsius;
        private String[] Celsius_type_info = new String[]{'Celsius','http://www.w3schools.com/webservices/',null,'0','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://www.w3schools.com/webservices/','true','false'};
        private String[] field_order_type_info = new String[]{'Celsius'};
    }
    public class TempConvertSoap {
        public String endpoint_x = 'http://www.w3schools.com/webservices/tempconvert.asmx';
        public Map<String,String> inputHttpHeaders_x;
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x;
        public String clientCert_x;
        public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://www.w3schools.com/webservices/', 'TmpCnv'};
        public String FahrenheitToCelsius(String Fahrenheit) {
            TmpCnv.FahrenheitToCelsius_element request_x = new TmpCnv.FahrenheitToCelsius_element();
            request_x.Fahrenheit = Fahrenheit;
            TmpCnv.FahrenheitToCelsiusResponse_element response_x;
            Map<String, TmpCnv.FahrenheitToCelsiusResponse_element> response_map_x = new Map<String, TmpCnv.FahrenheitToCelsiusResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.w3schools.com/webservices/FahrenheitToCelsius',
              'http://www.w3schools.com/webservices/',
              'FahrenheitToCelsius',
              'http://www.w3schools.com/webservices/',
              'FahrenheitToCelsiusResponse',
              'TmpCnv.FahrenheitToCelsiusResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.FahrenheitToCelsiusResult;
        }
        public String CelsiusToFahrenheit(String Celsius) {
            TmpCnv.CelsiusToFahrenheit_element request_x = new TmpCnv.CelsiusToFahrenheit_element();
            request_x.Celsius = Celsius;
            TmpCnv.CelsiusToFahrenheitResponse_element response_x;
            Map<String, TmpCnv.CelsiusToFahrenheitResponse_element> response_map_x = new Map<String, TmpCnv.CelsiusToFahrenheitResponse_element>();
            response_map_x.put('response_x', response_x);
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://www.w3schools.com/webservices/CelsiusToFahrenheit',
              'http://www.w3schools.com/webservices/',
              'CelsiusToFahrenheit',
              'http://www.w3schools.com/webservices/',
              'CelsiusToFahrenheitResponse',
              'TmpCnv.CelsiusToFahrenheitResponse_element'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.CelsiusToFahrenheitResult;
        }
    }
}

VisualForce Controller
public class TmpCntrl {

    Public String Celsius{get;set;}
    Public String Fahrenheit{get;set;}
    Public String FResult{get;set;}
    Public String CResult{get;set;}
    
    PageReference pageRef = ApexPages.currentPage();
    TmpCnv.TempConvertSoap TC = new TmpCnv.TempConvertSoap();
      
    public string FCalculate() {
        FResult = TC.CelsiusToFahrenheit(Celsius);
        return null;
    }
    
    public String CCalculate() {
        CResult = TC.FahrenheitToCelsius(Fahrenheit);
        return null;
    }
}

VisualForce Page
<apex:page controller="TmpCntrl">
    <apex:form >
        <apex:inputText value="{!Celsius}"/>
          <p>{!FResult}</p> 
        <apex:commandButton value="C2F" action="{!FCalculate}" rerender="all" >
            <apex:param name="Celsius" value="{!Celsius}" assignTo="{!FResult}"/>
        </apex:commandButton>
    </apex:form>
</apex:page>
Please give me some light.

Thanks.
Best Answer chosen by Adelchi Pelizzo
Bhanu MaheshBhanu Mahesh
Hi Adelchi Pelizzo,

The problem is with the return type of the action method,
 
public string FCalculate() {
        FResult = TC.CelsiusToFahrenheit(Celsius);
        return null;
    }

Try changing the return type to pageReference
public pageReference FCalculate() {
        FResult = TC.CelsiusToFahrenheit(Celsius);
        return null;
    }

Mark this as "SOLVED" if your issue resolved.

Thanks & Regards,
Bhanu Mahesh Gadi