Solved

SalesForce Syntax Error on SemiColon

Posted on 2013-01-10
1
1,411 Views
Last Modified: 2016-02-16
I am trying to build onto my webfront site and I am getting a semicolon error when I attempt to utilize the training guide for APEX. Here is the controller code that is generating the error on line column. I am getting the following error message "Error: StoreFrontController Compile Error: expecting a semi-colon, found '(' at line 16 column 30". This is on the line "public PageReference addToCart() {". If anyone could help me resolve this issue it would be greatly appreciated.
 

public class StoreFrontController {
 List<DisplayMerchandise> products;
 public List<DisplayMerchandise> getProducts() {
 if(products == null) {
 products = new List<DisplayMerchandise>();
 for(Merchandise__c item : [
 SELECT Id, Name, Description__c, Price__c, Total_Inventory__c
 FROM Merchandise__c]) {
 products.add(new DisplayMerchandise(item));
 }
 }
 return products;
 
List<DisplayMerchandise> shoppingCart = new List<DisplayMerchandise>();
 // Action method to handle purchasing process
 public PageReference addToCart() {
 for(DisplayMerchandise p : products) {
 if(0 < p.qtyToBuy) {
 shoppingCart.add(p);
 }
 }
 return null; // stay on the same page
 }
 
public String getCartContents() {
 if(0 == shoppingCart.size()) {
 return '(empty)';
 }
 String msg = '<ul>\n';
 for(DisplayMerchandise p : shoppingCart) {
 msg += '<li>';
 msg += p.name + ' (' + p.qtyToBuy + ')';
 msg += '</li>\n';
 }
 msg += '</ul>';
 return msg;
 }
 
 
 
}
 // Inner class to hold online store details for item
 public class DisplayMerchandise {
 private Merchandise__c merchandise;
 public DisplayMerchandise(Merchandise__c item) {
 this.merchandise = item;
 }
 // Properties for use in the Visualforce view
 public String name {
 get { return merchandise.Name; }
 }
 public String description {
 get { return merchandise.Description__c; }
 }
 public Decimal price {
 get { return merchandise.Price__c; }
 }
 public Boolean inStock {
 get { return (0 < merchandise.Total_Inventory__c); }
 }
 public Integer qtyToBuy { get; set; }
 }
 }
0
Comment
Question by:thenthorn1010
1 Comment
 
LVL 16

Accepted Solution

by:
krakatoa earned 500 total points
ID: 38764232
It looks to me as if you have this statement in the wrong place :

return products;
0

Featured Post

How does your email signature look on mobiles?

Do your employees use mobile devices to reply to emails? With mobile becoming increasingly important to the business world, it is in your best interest to make sure that your email signature looks great across all types of devices.

Join & Write a Comment

Suggested Solutions

Monitoring systems evolution, cloud technology benefits and cloud cost calculators business utility.
Big data transfers via information superhighways require special attention and protection. Learn more about the IT-regulations of the country where your server is located. Analyze cloud providers and their encryption systems for safe data transit. S…
This video teaches viewers about errors in exception handling.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now