• NEW.ax1607
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies

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);
          
         
          
          
          
                   
     }
     
 

Hello,

 

when I try open my chart in a tab I get the following error because my gerId =null;

List index out of bounds: 0

 

I don't know how to pass my account Id to Controller/ visualforce page, someone can help me please? thank you

 

My code:


public with sharing class Gauge2ChartController {
public List<Account> a;// = new Account(Name='');
public boolean render {get; set;}
public Integer currentYear = date.Today().year();
public Date last12Months = date.Today().addMonths(-12);
public Integer totalRevenue {get; set;}
public ID gerId {get; set;}

//Essa Classe é usada para mostrar o Gráfico nas accounts
//Grabbing the Accountid from the current record//
//Quando usamos ApexPages.StandardController controller no construtor quer dizer qu vamos chamar a classe como um extensions
//na classe visualforce page
public Gauge2ChartController(ApexPages.StandardController controller) {

render=true;

try{
        a = [SELECT Id, Name, Site, owner.name, phone,billingstreet,billingstate,billingcountry,billingcity FROM Account
                   WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
                   system.debug('testeprimeiro' + a);
}
catch(Exception ex1){
System.Debug('We did not find the Account' + ex1);
}
               
                  
        
}

public List<gaugeData> getData() {
     Integer TotalOpptys = 0;
     Integer TotalAmount = 0;
          Integer thisMonth = date.Today().month();
           
            system.debug('gerID ' + gerId);
          a = [SELECT Id, Name, Site, owner.name, phone,billingstreet,billingstate,billingcountry,billingcity FROM Account
                  WHERE Id = :gerId];
                   
                   system.debug('testeprimeiro' + a);
                  
           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);
            
          List<gaugeData> data = new List<gaugeData>();
          data.add(new gaugeData(Integer.valueOf(ClosedWonOpptys.get('numOpps')) + ' Opps', Integer.valueOf(ClosedWonOpptys.get('totalRevenue'))));
          system.debug('testeterceiro' + data);
           
          return data;
           
           
     }

    public class gaugeData {
        public String name { get; set; }
        public Integer size { get; set; }

        public gaugeData(String name, Integer data) {
            this.name = name;
            this.size = data;
        }
    }
    
}

 

Visaulaforce page:

 

<apex:page StandardController="Account" extensions="Gauge2ChartController" tabStyle="Chart__tab" >

    <apex:chart name="MyChart" height="250" width="400" animate="true" data="{!data}">
        <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:page>

 

I have created VF page and apex Controller to construct a Gauge chart but when I try open the chart I've this error message:

Attempt to de-reference a null object

 

Does anyone can help me please? I´m new on this and I don't know how can I solve this problem. Thnak you.

 

when I make debug the error are indicated in this code:

AggregateResult ClosedWonOpptys =[select SUM(Amount) totalRevenue, CALENDAR_MONTH(CloseDate) theMonth, COUNT(Name) numOpps
from Opportunity
where AccountId =: acctId
and StageName = 'Closed Won'
and CALENDAR_MONTH(CloseDate) =: thisMonth
GROUP BY CALENDAR_MONTH(CloseDate) LIMIT 1];

 

my Class apex:

public class GaugeChartController {
public Account a {get; set;}
public String acctId {get;set;}
public Integer totalRevenue {get; set;}
//public Integer thisMonth = date.Today().month();
public boolean render {get; set;}

public GaugeChartController(ApexPages.StandardController controller){
acctId = controller.getRecord().Id;

//render=true;

/* try{
a = [SELECT Id, Name, Site, owner.name, phone,billingstreet,billingstate,billingcountry,billingcity FROM Account
WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
}
catch(Exception ex1){
System.Debug('We did not find the Account' + ex1);
}

AggregateResult renderCheck = [select Count(id) numOpps, SUM(Amount) totalRev from Opportunity where Accountid = :a.id
AND CALENDAR_YEAR(CloseDate) = :thisMonth];

//checking if there are any related Opps, and aggregating their revenue
System.Debug('Number of Opps returned in query is ' + Integer.valueOf(renderCheck.get('numOpps')));
if(Integer.valueOf(renderCheck.get('numOpps')) > 0){
render=true;
totalRevenue = Integer.valueOf(renderCheck.get('totalRev'));
}*/


}

public List<gaugeData> getData() {
    Integer TotalOpptys = 0;
    Integer TotalAmount = 0;
    Integer thisMonth = date.Today().month();

 

   AggregateResult ClosedWonOpptys =[select SUM(Amount) totalRevenue, CALENDAR_MONTH(CloseDate)  theMonth, COUNT(Name) numOpps
                           from Opportunity
                           where AccountId =: acctId
                           and StageName = 'Closed Won'
                           and CALENDAR_MONTH(CloseDate) =: thisMonth
                           GROUP BY CALENDAR_MONTH(CloseDate) LIMIT 1];

   List<gaugeData> data = new List<gaugeData>();
   system.debug('debug2' + data.add(new gaugeData(Integer.valueOf(ClosedWonOpptys.get('numOpps')) + ' Deals', Integer.valueOf(ClosedWonOpptys.get('totalRevenue')))));


return data;


}

public class gaugeData {
public String name { get; set; }
public Integer size { get; set; }

 

public gaugeData(String name, Integer data) {
this.name = name;
this.size = data;
}
}
}

 

VF Page:

<apex:page standardController="Account" extensions="GaugeChartController">
<apex:chart name="MyChart" height="300" width="450" animate="true" data="{!data}">
<apex:axis type="Gauge" position="gauge" title="Closed Won Opportunities" minimum="0" maximum="30000" 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:page>

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);
          
         
          
          
          
                   
     }
     
 

Hello,

 

when I try open my chart in a tab I get the following error because my gerId =null;

List index out of bounds: 0

 

I don't know how to pass my account Id to Controller/ visualforce page, someone can help me please? thank you

 

My code:


public with sharing class Gauge2ChartController {
public List<Account> a;// = new Account(Name='');
public boolean render {get; set;}
public Integer currentYear = date.Today().year();
public Date last12Months = date.Today().addMonths(-12);
public Integer totalRevenue {get; set;}
public ID gerId {get; set;}

//Essa Classe é usada para mostrar o Gráfico nas accounts
//Grabbing the Accountid from the current record//
//Quando usamos ApexPages.StandardController controller no construtor quer dizer qu vamos chamar a classe como um extensions
//na classe visualforce page
public Gauge2ChartController(ApexPages.StandardController controller) {

render=true;

try{
        a = [SELECT Id, Name, Site, owner.name, phone,billingstreet,billingstate,billingcountry,billingcity FROM Account
                   WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
                   system.debug('testeprimeiro' + a);
}
catch(Exception ex1){
System.Debug('We did not find the Account' + ex1);
}
               
                  
        
}

public List<gaugeData> getData() {
     Integer TotalOpptys = 0;
     Integer TotalAmount = 0;
          Integer thisMonth = date.Today().month();
           
            system.debug('gerID ' + gerId);
          a = [SELECT Id, Name, Site, owner.name, phone,billingstreet,billingstate,billingcountry,billingcity FROM Account
                  WHERE Id = :gerId];
                   
                   system.debug('testeprimeiro' + a);
                  
           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);
            
          List<gaugeData> data = new List<gaugeData>();
          data.add(new gaugeData(Integer.valueOf(ClosedWonOpptys.get('numOpps')) + ' Opps', Integer.valueOf(ClosedWonOpptys.get('totalRevenue'))));
          system.debug('testeterceiro' + data);
           
          return data;
           
           
     }

    public class gaugeData {
        public String name { get; set; }
        public Integer size { get; set; }

        public gaugeData(String name, Integer data) {
            this.name = name;
            this.size = data;
        }
    }
    
}

 

Visaulaforce page:

 

<apex:page StandardController="Account" extensions="Gauge2ChartController" tabStyle="Chart__tab" >

    <apex:chart name="MyChart" height="250" width="400" animate="true" data="{!data}">
        <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:page>

 

This just started today (9/26/2011) and won't let me save the file to force.com. The file is a long existing apex class. Only making some minor changes.

 

 

Save error: Unable to perform save on all files:

 

com.salesforce.ide.api.metadata.types.Metadata$JaxbAccessorF_fullName cannot be cast to com.sun.xml.internal.bind.v2.runtime.reflect.Accessor

 

I deleted the whole project and re-added it. I was able to get everything back, then tried to make changes again. Same error. I tried to refresh my file from the ORG and received a pop up with the same error.