You need to sign in to do that
Don't have an account?
Save error: Unknown method ' mapController.getData()
Hi guys,
When I try save my VF I've this error message:
Save error: Unknown method ' mapController.getData()
but in my apex class mapController I've this method.
Someone can help me plesae? Thank you
a litlle code of VF page:
<apex:pageBlockSection title="Dashboard" id="up" rendered="false">
<apex:chart name="MyChart" height="250" width="400" animate="true" data="{!listgouge}">
<apex:axis type="Gauge" position="gauge" title="Closed Won Opportunities" minimum="0" maximum="50000" steps="10"/>
<apex:gaugeSeries dataField="size" donut="50" colorSet="#78c953,#ddd"/>
</apex:chart>
<script>
MyChart.on('beforeconfig', function(config) {
config.axes[0].margin=-10;
});
</script>
</apex:pageBlockSection>
<pre id="log"></pre>
</apex:pageBlock>
<apex:actionFunction name="chart" action="{!getData}" rerender="up" immediate="true">
<apex:param name="acc" value="" assignTo="{!xx}"></apex:param>
</apex:actionFunction>
apex class - getData()
public void getData(ID acc){
Integer TotalOpptys = 0;
Integer TotalAmount = 0;
Integer thisMonth = date.Today().month();
a = [SELECT Id, Name, Site, owner.name, phone,billingstreet,billingstate,billingcountry,billingcity FROM Account
WHERE Id = :acc];
if(a.isEmpty()){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: List is empty.');
}
AggregateResult ClosedWonOpptys = [select SUM(Amount) totalRevenue, CALENDAR_YEAR(CloseDate) theYear, COUNT(Name) numOpps
from Opportunity
where Accountid = :a.get(0).Id and StageName = 'Closed Won'
and CALENDAR_YEAR(CloseDate) = :currentYear
GROUP BY CALENDAR_YEAR(CloseDate) LIMIT 1];
system.debug('testeterceiro' + ClosedWonOpptys);
system.debug('test account acct2'+ acct);
//List<gaugeData> data = new List<gaugeData>();
listgouge.add(new gaugeData(Integer.valueOf(ClosedWonOpptys.get('numOpps')) + ' Opps', Integer.valueOf(ClosedWonOpptys.get('totalRevenue'))));
//system.debug('testeterceiro' + data);
//system.debug('TESTAR o metodo DATA' + data);
}
Hi,
You can't call a parametrised method from visual force like getData(ID acc).
if u want to call a method from visual force page,u need to define a methot without any parameter.
Please le me know if u have any problem on same and if this post help u please give KUDOS by click on star at left.
When I look at the code - I understand that function getData() should be inside the controller class
Error stated that the function could not be found in the controller - could you please confirm if the function is available within the class?
Hi puja thank you for your replay.
I put "ID acc" in the method getData because I need get account id in this method so when I click in the google maps marker I can get the ID and open a windowflow with my chart.
Hi Sonam, thank you for your reply.
Yes my method getData(ID acc) is inside the controller class:
public with sharing class mapController {
public mapController(){
List<gaugeData> listgouge = new List<gaugeData>();
system.debug('test account acct' + acct);
a = [SELECT Id, Name, Site, owner.name, phone,billingstreet,billingstate,billingcountry,billingcity FROM Account
WHERE Id = :gerId];
searchText = ApexPages.currentPage().getParameters().get('q');
render=true;
getData(a[0].id);
}
.....
public void getData(ID acc){
Integer TotalOpptys = 0;
Integer TotalAmount = 0;
Integer thisMonth = date.Today().month();
a = [SELECT Id, Name, Site, owner.name, phone,billingstreet,billingstate,billingcountry,billingcity FROM Account
WHERE Id = :acc];
if(a.isEmpty()){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: List is empty.');
}
AggregateResult ClosedWonOpptys = [select SUM(Amount) totalRevenue, CALENDAR_YEAR(CloseDate) theYear, COUNT(Name) numOpps
from Opportunity
where Accountid = :a.get(0).Id and StageName = 'Closed Won'
and CALENDAR_YEAR(CloseDate) = :currentYear
GROUP BY CALENDAR_YEAR(CloseDate) LIMIT 1];
system.debug('testeterceiro' + ClosedWonOpptys);
system.debug('test account acct2'+ acct);
//List<gaugeData> data = new List<gaugeData>();
listgouge.add(new gaugeData(Integer.valueOf(ClosedWonOpptys.get('numOpps')) + ' Opps', Integer.valueOf(ClosedWonOpptys.get('totalRevenue'))));
//system.debug('testeterceiro' + data);
//system.debug('TESTAR o metodo DATA' + data);
}
....
}
VF page
<apex:page Controller="mapController" tabStyle="GEO__tab" action="{!find}" id="page" sidebar="false">
....
<apex:pageBlockSection title="Dashboard" id="up" rendered="false" controller="mapController">
<apex:chart name="MyChart" height="250" width="400" animate="true" data="{!listgouge}">
<apex:axis type="Gauge" position="gauge" title="Closed Won Opportunities" minimum="0" maximum="50000" steps="10"/>
<apex:gaugeSeries dataField="size" donut="50" colorSet="#78c953,#ddd"/>
</apex:chart>
<script>
MyChart.on('beforeconfig', function(config) {
config.axes[0].margin=-10;
});
</script>
</apex:pageBlockSection>
<pre id="log"></pre>
</apex:pageBlock>
<apex:actionFunction name="chart" action="{!getData}" rerender="up" immediate="true">
<apex:param name="acc" value="" assignTo="{!xx}"></apex:param>
</apex:actionFunction>