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
sunithasunitha 

Compile Error: unexpected token: '{' at line 2 column 43

 

hi, here Iam trying to implement some apex code for display dashdoard
 through vf pages. while compiling the apex class i got the error unexpected token

 

 

here iam attaching apex class code and vf page code. please any one can clear this error

 

 

public class OppsController {
publicApexPages.StandardSetControllersetCon{
get {
if(setCon == null) {
setCon = newApexPages.StandardSetController(Database.getQueryLocator(
                      [SELECT name, type, amount, closedate FROM Opportunity]));
setCon.setPageSize(5);
            }
returnsetCon;
        }
set;
    }

public List<Opportunity>getOpportunities() {
return (List<Opportunity>) setCon.getRecords();
    }
}

 

 

 

vf page code

   

<apex:page controller="OppsController">

<apex:chart data="{!Opportunities}" width="600" height="400">

<apex:axis type="Category" position="left" fields="Name" title="Opportunities"/>

<apex:axis type="Numeric" position="bottom" fields="Amount" title="Amount"/>

<apex:barSeries orientation="horizontal" axis="bottom"xField="Name"yField="Amount"/>

</apex:chart>

<apex:dataTable value="{!Opportunities}"var="opp">

<apex:column value="{!opp.name}"/>

<apex:column value="{!opp.amount}"/>

</apex:dataTable>

</apex:page>

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9

may be you would like to add some spaces ;)

 

public class OppsController {
public ApexPages.StandardSetController setCon{
get {
if(setCon == null) {
setCon = newApexPages.StandardSetController(Database.getQueryLocator(
                      [SELECT name, type, amount, closedate FROM Opportunity]));
setCon.setPageSize(5);
            }
returnsetCon;
        }
set;
    }

public List<Opportunity>getOpportunities() {
return (List<Opportunity>) setCon.getRecords();
    }
}

 

All Answers

Avidev9Avidev9

may be you would like to add some spaces ;)

 

public class OppsController {
public ApexPages.StandardSetController setCon{
get {
if(setCon == null) {
setCon = newApexPages.StandardSetController(Database.getQueryLocator(
                      [SELECT name, type, amount, closedate FROM Opportunity]));
setCon.setPageSize(5);
            }
returnsetCon;
        }
set;
    }

public List<Opportunity>getOpportunities() {
return (List<Opportunity>) setCon.getRecords();
    }
}

 

This was selected as the best answer
souvik9086souvik9086

Copy Paste this code and check

 

public class OppsController {
public ApexPages.StandardSetController setCon{
get {
if(setCon == null) {
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
[SELECT name, type, amount, closedate FROM Opportunity]));
setCon.setPageSize(5);
}
return setCon;
}
set;
}

public List<Opportunity> getOpportunities() {
return (List<Opportunity>) setCon.getRecords();
}
}

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

sunithasunitha

thank u

 

 

it is working