Solved

SalesForce Syntax Error on SemiColon

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

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…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Suggested Courses

623 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