• DMalone
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I'm on the second to last unit of the Visualforce Basics module, called Creating & Using Custom Controllers.
I THINK I have followed everything correctly (being new to coding) but I'm getting an error when in the section Add A New Action Method:

line 7: expecting a semi-colon, found "("


The custom controller I am trying to use is as follows and the line in bold is line 7:

public class ContactsListController {
    private String sortOrder = 'LastName';
        public List<Contact> getContacts() {
    public void sortByLastName() {
    this.sortOrder = 'LastName';
}    
public void sortByFirstName() {
    this.sortOrder = 'FirstName';
}   
        List<Contact> results = Database.query(
            'SELECT Id, FirstName, LastName, Title, Email ' +
            'FROM Contact ' +
            'ORDER BY ' + sortOrder + ' ASC ' +
            'LIMIT 10'
        );
        return results;
    }
}


Any ideas on where I have gone wrong?

Thanks
Dan
I'm on the second to last unit of the Visualforce Basics module, called Creating & Using Custom Controllers.
I THINK I have followed everything correctly (being new to coding) but I'm getting an error when in the section Add A New Action Method:

line 7: expecting a semi-colon, found "("


The custom controller I am trying to use is as follows and the line in bold is line 7:

public class ContactsListController {
    private String sortOrder = 'LastName';
        public List<Contact> getContacts() {
    public void sortByLastName() {
    this.sortOrder = 'LastName';
}    
public void sortByFirstName() {
    this.sortOrder = 'FirstName';
}   
        List<Contact> results = Database.query(
            'SELECT Id, FirstName, LastName, Title, Email ' +
            'FROM Contact ' +
            'ORDER BY ' + sortOrder + ' ASC ' +
            'LIMIT 10'
        );
        return results;
    }
}


Any ideas on where I have gone wrong?

Thanks
Dan