+ Start a Discussion
Lohith MatamLohith Matam 

vf with controller

Create a Visualforce page that uses a custom controller to display a list of cases with the status of 'New'.The page must be named 'NewCaseList'.
The custom controller Apex class must be named 'NewCaseListController'.
The 'NewCaseListController' Apex class must have a publically scoped method named 'getNewCases'.
The 'getNewCases' Apex method should have the return type of 'List' and return a list of case records with the ID and CaseNumber fields and filtered to only have a status of 'New'.
The 'NewCaseList' Visualforce page must use an apex:repeat component which is bound to 'newCases'.
The apex:repeat component must refer to the var attribute as 'case'.
Within the apex:repeat component, bind a apex:outputLink component to the ID of the case so that the page directs the user to the detail page of the respective case record
andy81andy81
HIt Like If this Solves your issue so that others will have reference for it.
VF Page

<apex:page controller="NewCaseListController">
  <apex:repeat value="{!NewCases}" var="Case">

<apex:outputLink onclick="/?id={!Case.Id}">
  {!Case.CaseNumber}
  </apex:outputLink>
  </apex:repeat>
  
</apex:page>

Controller:-

public with sharing class NewCaseListController {
    public List<Case> getNewCases() {
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber, Origin, Status, Account.Name ' +
            'FROM Case ' +
            'LIMIT 10'
    );
    return results;
}

}
Charles FortuneCharles Fortune
Slight modification to get link working w/ some formatting. Other than that, all else worked great!!

<apex:page controller="NewCaseListController">
  
    <apex:repeat value="{!NewCases}" var="Case">
        <li>
        <apex:outputLink value="/{!Case.Id}">{!Case.CaseNumber}</apex:outputLink>
          </li>
    </apex:repeat>
          
</apex:page>
SWETA SINGH 35SWETA SINGH 35
Hello all,I have cleared this trail..Please find the correct code below:

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

  
   
  </apex:repeat>
 
 
</apex:page>

( Write the below code Inside the apex class)

public class NewCaseListController {

list<case> newcase = new list<case>();
    public list<case> GetNewCases() 
    {
    newcase = [Select Id,CaseNumber from case where status='New'];
    
        return newcase;
    }


   

}
Ilya IvanovskiyIlya Ivanovskiy
<apex:page controller="NewCaseListController">
    <apex:repeat var="case" value="{!NewCases}">
        <li>
            <apex:outputLink value="/{!case.id}">{!case.id}</apex:outputLink>
            - {!case.CaseNumber}
            - {!case.Account.Name}
        </li>
    </apex:repeat>
</apex:page>
public class NewCaseListController {    
    private String sortOrder = 'CaseNumber';     
    public List<Case> getNewCases() {        
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber, Account.name ' +
            'FROM Case ' +
            'ORDER BY ' + sortOrder + ' ASC ' 
        );
        return results;  
    }    
}

Visualforce Basics  Create & Use Custom Controllers
 
Soumyadip SomadderSoumyadip Somadder
Hi,
Please find my codes

Vf Code

<apex:page controller="NewCaseListController">
    <apex:form>
        <apex:pageBlock title="Case List" id="cases_list">
         <apex:repeat values="{!NewCases}" var="Case">
                 <apex:outputLink value="/{!Case.Id}">{!Case.CaseNumber}</apex:outputLink>
          </apex:repeat>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Code

public class NewCaseListController {
    public List<Case> getNewCases(){
       List<Case> results = Database.query(
            'SELECT id, CaseNumber ' +
            'FROM Case ' +
            'WHERE Status=\'New\'');
        
        return results;
    }
}

Whenever I amexecuting the code , I am receiving this error 

"Unsupported attribute values in <apex:repeat> in NewCaseList at line 6 column 56"

Can anyone put some light on it.

Thanks
Soumyadip

 
Monika Pawar 9Monika Pawar 9
For the Vf Page-:

<apex:page Controller="NewCaseListController " >
    <apex:repeat value="{!newCases}" var="case" id="theRepeat">
    <li><apex:outputLink value="/{!case.id}">{!case.ID }</apex:outputLink></li>
         <li><apex:outputLink value="/{!case.id}">{!case.CaseNumber }</apex:outputLink></li>
    </apex:repeat>
</apex:page>



For The Apex Class-:

public class NewCaseListController
{    
    private String sortOrder = 'CaseNumber';     
    public List<Case> getNewCases() {        
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber, Account.name ' +
            'FROM Case ' +
            'ORDER BY ' + sortOrder + ' ASC ' 
        );
        return results;  
    }    
}
Zoltán AntalZoltán Antal

Hello Trailblazers!

In that challenge there is a small bug. The challenge ask a case list filtered by New. However it accept the challenge without filter. So...

For the VF Page:
<apex:page controller="NewCaseListController">
    <apex:form >
        <apex:pageBlock title="Case List" id="case_list">
            
            <!-- Case List goes here -->
            <apex:repeat value="{! newCases }" var="case">
                <li><apex:outputLink value="/{!case.id}">{!case.CaseNumber}</apex:outputLink></li>
            </apex:repeat>

        </apex:pageBlock>
    </apex:form>
</apex:page>

For the Apex class:
public class NewCaseListController {

    public List<Case> getNewCases() {        
        List<Case> newCases = Database.query('SELECT Id, CaseNumber FROM Case');
        return newCases;
    }

}

 

Chhavi Singhal 13Chhavi Singhal 13
Hello Everyone,
I tried this and it works perfect.See if this can help you.
VISUALFORCE PAGE :-
<apex:page controller="NewCaseListController">
    <apex:pageBlock title="Case List with Status as New">
        <apex:pageBlockSection >
            <!-- Case List with Status=New --> 
            <apex:repeat value="{!NewCases}" var="case">
                <apex:outputLink value="/{!case.ID}">
                    <apex:outputText value="{!case.casenumber}"/>
                </apex:outputLink> 
            </apex:repeat> 
        </apex:pageBlockSection> 
    </apex:pageBlock> 
</apex:page>

NewCaseListController CLASS :-
public class NewCaseListController 
{    
    List<Case> results=new List<Case>();
	public List<Case> getNewCases() 
    {
    	results=[Select ID,CaseNumber from Case where Status='New'];
    	return results;
	}
}

Thanks,
Chhavi Singhal​​​​​​​
​​​​​​​
Evaristo CaraballoEvaristo Caraballo

Hi People,

 

I have seen the code used to solve this particular problem but I don't understand why this works.

Is {!NewCases} the call for the public method in NewCaseListController class, GetNewCases? Is Get a keyword in Apex?

Thanks in advance for your comments here.

 

Naveen Reddy BeeramNaveen Reddy Beeram
Plz help me......

Create a Visualforce page that uses a custom controller to display a list of cases with the status of New.
Apex class:

public class NewCaseListController {
    public List<Case> getNewCases(){
        List<Case> Cases =[SELECT Id,CaseNumber From Case Where      status='New'];
        return Cases;
    }
}

Visual Page:

<apex:page controller="NewCaseListController">
  <apex:repeat value="{!NewCases}" var="Case">

<apex:outputLink onclick="/?id={!Case.Id}">
  {!Case.CaseNumber}
  </apex:outputLink>
  </apex:repeat>
  
</apex:page>

Error:

Challenge not yet complete in naveen98k@salesforce.com
The method 'getNewCases' isn't working as expected. Either the method doesn't exist or it doesn't return the expected list of cases.


Plz help me......
Surya Pratap Singh 13Surya Pratap Singh 13
This is perfectly working.. Mark it correct if you find it right

Vf :-
<apex:page controller="NewCaseListController">
 
        <apex:repeat value="{! NewCases}" var="case">
            <li>><apex:outputLink value="/{!case.id}" target="_new">Case {! case.caseNumber}   
                </apex:outputLink>   </li> 
            </apex:repeat>
    
     </apex:page>

Apex :-
public class NewCaseListController {

    public List<Case> getNewCases() {
        List<Case> results = Database.query(
            'SELECT Id, CaseNumber, Status ' +
            'FROM Case ' +
            'WHERE Status = \'New\' '
        );
   
    return results;
    }

}

​​​​​​​
Varalakshmi Niharika JaguVaralakshmi Niharika Jagu
Use the following code to get 100% in your challenge!

NewCaseListController:
public class NewCaseListController {
    public List<Case> getNewCases() {
        List<Case> results = Database.query('SELECT Id, CaseNumber, Subject, Status FROM Case WHERE Status=\'New\'');
        return results;
    }
}


NewCaseList (page)
<apex:page controller="NewCaseListController">
    <apex:form>
    	<apex:pageBlock title="Case List" id="cases_list">
        	<apex:repeat value="{! newcases}" var="case">
            	<li>
                    <apex:outputLink value="/{! case.Id}" target="_new">Case {! case.CaseNumber}
                    </apex:outputLink>
                </li>
            </apex:repeat>
        </apex:pageBlock>
    </apex:form>
</apex:page>