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
Aman Singh ChhokarAman Singh Chhokar 

How to Display Integer value got from SOQL Query (Apex Class) to Visualforce Page

I am new to Apex and trying to access the value from Custom Controller having SOQL query and show it on visualforce page as an Output link.
Visualforce snippet:
<div class="count"><apex:outputText value="{!Records}"/></div>
Apex Code Snippet:
public Integer getDisplayQueryList() { Records = 0; Records = [select count() from Case where Type like 'MDD Increase from WSC']; return Records; }
Also I have read about the AggregateResult[] which might be the best way to use but not sure how to use it properly. My main aim is to search & Count for all Cases which are NOT Closed & of Type = MDD Increase from WSC and then display that count in the visual force page.
Any Help would be much appreciated.
Best Answer chosen by Aman Singh Chhokar
Rohit K SethiRohit K Sethi
Hi,

Whenever you use only value to display we use the getter method. So use the below code for display value :
 
<div class="count">
       <apex:outputText value="{!displayQueryList}"/>
​</div>


Thanks.

All Answers

Rohit K SethiRohit K Sethi
Hi,

Whenever you use only value to display we use the getter method. So use the below code for display value :
 
<div class="count">
       <apex:outputText value="{!displayQueryList}"/>
​</div>


Thanks.
This was selected as the best answer
VineetKumarVineetKumar
Controller :
public Integer Records{
	get;
	set{
		Integer recordCount = [SELECT count() FROM Case WHERE Type like 'MDD Increase from WSC' AND isClosed = true];
		this.Records = recordCount;
	}
}
Page:
<div class="count">
    <apex:outputText value="{!Records}"/>
</div>
Aman Singh ChhokarAman Singh Chhokar
Thank you to both Rohit & Vineet.