Solved

SalesForce Syntax Error on SemiColon

Posted on 2013-01-10
1
1,438 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

When ransomware hits your clients, what do you do?

MSPs: Endpoint security isn’t enough to prevent ransomware.
As the impact and severity of crypto ransomware attacks has grown, Webroot fought back, not just by building a next-gen endpoint solution capable of preventing ransomware attacks but also by being a thought leader.

Question has a verified solution.

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

When speed and performance are vital to revenue, companies must have complete confidence in their cloud environment.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

734 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