You need to sign in to do that
Don't have an account?
Francisco Garcia 34
Newbie question... Why is my third table not showing up? Confused on how data is transferred from Apex to VF
Hey guys! This should be my last question for a while, thanks for all the help so far!
I dont think i understand how data is passed between Apex into the controller... I though you create a List of objects and and you store a query to make it display on the table
Here is my Apex:
I think it the line this.case2 is completely wrong and it causing the issue... I dont think it is even transferring data... Could somebody help me fix it and also explain (or share a source) how the query information is actually being transfer into my visualforce page.
This is my VF page:
The first two tables are correct. The last should display a table of the 5 most recent cases, however my program crashes when I attempt to preview this code I have shared.
Once again thanks for all the amazing support!
I dont think i understand how data is passed between Apex into the controller... I though you create a List of objects and and you store a query to make it display on the table
Here is my Apex:
public class controllerClass { public Case myCase {get; set;} public List<Case> cases {get; set;} public List<Account> accounts {get; set;} public List<Case> cases2 {get; set;} public controllerClass(ApexPages.StandardController stdController){ this.myCase = (Case)stdController.getRecord(); //Query Obtains the Accounts with open cases and displays them as a table in firstProject.vfp this.cases = [SELECT AccountId, Status, Subject FROM Case WHERE IsClosed = False ORDER BY AccountId DESC]; //Query Obtains the Accounts with no cases this.accounts = [Select Name FROM Account WHERE Id NOT IN (SELECT AccountId FROM Case)]; //Query Obtains the 5 most recent cases this.cases2 = [SELECT Subject, CreatedDate FROM Case ORDER BY CreatedDate Limit 5]; } }
I think it the line this.case2 is completely wrong and it causing the issue... I dont think it is even transferring data... Could somebody help me fix it and also explain (or share a source) how the query information is actually being transfer into my visualforce page.
This is my VF page:
<apex:page standardController="Case" extensions="controllerClass"> <apex:pageBlock title="Table of Accounts with Open Cases"> <apex:pageBlockTable value="{!Cases}" var="c"> <apex:column value="{!c.AccountId}"/> <apex:column value="{!c.Status}"/> <apex:column value="{!c.Subject}"/> </apex:pageBlockTable> </apex:pageBlock> <apex:pageBlock title="Table of Accounts with no Cases"> <apex:pageBlockTable value="{!Accounts}" var="a"> <apex:column value="{!a.Name}"/> </apex:pageBlockTable> </apex:pageBlock> <apex:pageBlock title="Table of 5 most recent cases"> <apex:pageBlockTable value="{!Cases}" var="c"> <apex:column value="{!c.Subject}"/> <apex:column value="{!c.CreatedDate}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>
The first two tables are correct. The last should display a table of the 5 most recent cases, however my program crashes when I attempt to preview this code I have shared.
Once again thanks for all the amazing support!
For the third table, you had used Cases instead of cases2 in VF page
All Answers
For the third table, you had used Cases instead of cases2 in VF page