You need to sign in to do that
Don't have an account?
Carlton Brumbelow
Query results in class not showing on Visualforce page
Hi, I'm trying to use an apex class to query the database and display the results on a visualforce page. The class (and page) saves without error, but nothing displays on the page when I navigate there. I'm new to this and know what's missing is likely very simple, but any help would be appreciated.
Here's the class:
Thanks everyone!
Here's the class:
public class SSReportTest { public String casenumber = 'JAMF-0160404'; public List<sObject> numberList {get; set;} public List<sObject> getList() { numberList = Database.query('SELECT Case.Owner from Case where Case.CaseNumber = "J-0160404"'); return numberList; } }And here is the visualforce page:
<apex:page controller="SSReportTest"> <apex:pageBlock > {!numberList} </apex:pageBlock> </apex:page>
Thanks everyone!
{
public String casenumber = 'JAMF-0160404';
public List<sObject> getList()
{
List<sObject> numberList = Database.query('SELECT OwnerId from Case where CaseNumber =: casenumber');
return numberList;
}
}
<apex:page controller="SSReportTest">
<apex:pageBlock>
<apex:pageBlockTable value="{!List}" var="numlist">
<apex:column value="{!numlist.OwnerId}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
if your page still doesn't shows any value then case number might be wrong.
All Answers
Try above code in VF Page
{
public String casenumber = 'JAMF-0160404';
public List<sObject> getList()
{
List<sObject> numberList = Database.query('SELECT OwnerId from Case where CaseNumber =: casenumber');
return numberList;
}
}
<apex:page controller="SSReportTest">
<apex:pageBlock>
<apex:pageBlockTable value="{!List}" var="numlist">
<apex:column value="{!numlist.OwnerId}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
if your page still doesn't shows any value then case number might be wrong.
Thank you for attempting to help. I think we're close, but when I attmempt to save the visualforce page the error I'm receiving now is:
"Unknown Property: SObject.Owner"
Any ideas? I'll have some time in a bit to do my own research as well.
Thanks!
However, in the visualforce page we set the value of the PageBlock to !List. Why?
When I try changing list to !numberList I am told that there is no property of SSReportTest.numberList. I'm not making the conneciton as to why it's working as it currently is.
we can also define get property as follows. or define a function both will have the same functionality. The list variable "cl" in this case is independent and can be named anything.
The reason {!numberList} was unaccessible was because it was local to the getList() property.To make it accessible you will have to declare another property getnumberList{}.