Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SalesForce Syntax Error on SemiColon

Posted on 2013-01-10
1
Medium Priority
?
1,461 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 2000 total points
ID: 38764232
It looks to me as if you have this statement in the wrong place :

return products;
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
As managed cloud service providers, we often get asked to intervene when cloud deployments go awry. Attracted by apparent ease-of-use, flexibility and low computing costs, companies quickly adopt leading public cloud platforms such as Amazon Web Ser…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

721 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