Solved

SalesForce Syntax Error on SemiColon

Posted on 2013-01-10
1
1,422 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
Learn how the use of a bunch of disparate tools requiring a lot of manual attention led to a series of unfortunate backup events for one company.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

770 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