function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Natasha MartinNatasha Martin 

Custom Controller not recognized in Visualforce Basics module

I’m trying to finish up the Visualforce Basics module in Trailhead and keep receiving this error:
Challenge not yet complete... here's what's wrong: 
No Apex class named 'NewCaseListController' was found
 
When I view the setup page in my developer account it shows my Apex class is listed as “ContactsListController” but when I open the class it shows the correct name – “NewCaseListController”.
 
I’ve tried deleting the class and editing the name and nothing is changing the name shown on the setup page.
 
Could this be causing the error message above in Trailhead?
Any suggestions on how to fix it?
(see screenshot and code below)

Controller code:
public class NewCaseListController {
List<Case> results = new List<Case>();


private String sortOrder = 'CaseNumber';
public List<Case> getNewCases() {
    results = [SELECT Id, CaseNumber FROM Case WHERE status = 'new'];

    return results;
    }
}

Page code:
<apex:page controller="NewCaseListController">
    <apex:form >
        <apex:pageBlock title="Case List" id="Case_list">
            <!-- Case_list -->
         <apex:repeat value="{!newCases}" var="case">
         <table style="width:1000px;">
              <tr>
                  <br/>
                  <apex:outputLink value="/{!case.Id}" style="width:160px">{!case.Id}</apex:outputLink>
                  <br/>
               </tr>
           </table>
        </apex:repeat>     
        </apex:pageBlock>
    </apex:form>
</apex:page>



User-added image
 
Best Answer chosen by Natasha Martin
Chandra Sekhar CH N VChandra Sekhar CH N V
Don't see any issues there but I am posting my code which worked for me to pas the challenge:
 
//Controller
public class NewCaseListController {
public list<Case> getNewCases(){
list<Case> clist = [select CaseNumber,status from Case where status='New'];
return clist;
}
}


//VF Page

<apex:page controller="NewCaseListController">
<apex:repeat value="{!newCases}" var="case">
<apex:outputLink value="/{!case.id}"></apex:outputLink>
</apex:repeat>  
</apex:page>

 

All Answers

Chandra Sekhar CH N VChandra Sekhar CH N V
Don't see any issues there but I am posting my code which worked for me to pas the challenge:
 
//Controller
public class NewCaseListController {
public list<Case> getNewCases(){
list<Case> clist = [select CaseNumber,status from Case where status='New'];
return clist;
}
}


//VF Page

<apex:page controller="NewCaseListController">
<apex:repeat value="{!newCases}" var="case">
<apex:outputLink value="/{!case.id}"></apex:outputLink>
</apex:repeat>  
</apex:page>

 
This was selected as the best answer
Natasha MartinNatasha Martin
Thank you! After a couple of days I deleted the original VF page and Apex class and rebuilt them and I was able to get it to go through.