You need to sign in to do that
Don't have an account?
Girbson Bijou 8
Extension Controller
Hi All,
I have an issue with using Controller Extension in code below.
When i use the The custom Controller, the data display well in the VF Page. But when i use the controller as extensions, the code savde but the data are not displayed in the VF Page.
Make a look for me please.
Controller
VF Page
I have an issue with using Controller Extension in code below.
When i use the The custom Controller, the data display well in the VF Page. But when i use the controller as extensions, the code savde but the data are not displayed in the VF Page.
Make a look for me please.
Controller
public class OrdercompilerController{ public OrdercompilerController(ApexPages.StandardController controller) { } // public Order_Compiler__c oc { get; set; } public List <String> OrderNumberList { get; set; } //public List<Order_Compiler__c> compiler = New List<Order_Compiler__c>(); public List<AggregateResult> allItems{get;set;} String compilerId; public OrdercompilerController(){ OrderNumberList= new List<String>(); compilerId= ApexPages.currentPage().getParameters().get('id'); // oc = new Order_Compiler__c(); // try{ // oc = [ SELECT Name, Account__r.Parent.Distribution_Center__c, Account__r.Parent.Address__c,Account__r.Parent.Phone FROM Order_Compiler__c Where Id =: compilerId LIMIT 1]; List<Delivery__c> del = new List<Delivery__c> (); del = [SELECT id , Name From Delivery__c WHERE Compiler__c =: compilerId]; //List<String> OrderNumberList = new List<String>() ; for( Delivery__c d : del){ OrderNumberList.add(d.Name); } //compiler = [SELECT id FROM Order_Compiler__c WHERE id =:compilerId LIMIT 1]; allItems= [SELECT Pro__c, UOM__c,SUM(Quantity__c)Qty FROM Item_Distributed__c WHERE compilerId__c =: compilerId GROUP BY Pro__c, UOM__c HAVING SUM(Quantity__c) >0 ORDER BY Pro__c, UOM__c limit 100000]; // } //catch(Exception e) //{ // System.debug(e.getMessage()); // } } }
VF Page
public class OrdercompilerController{ public OrdercompilerController(ApexPages.StandardController controller) { } // public Order_Compiler__c oc { get; set; } public List <String> OrderNumberList { get; set; } //public List<Order_Compiler__c> compiler = New List<Order_Compiler__c>(); public List<AggregateResult> allItems{get;set;} String compilerId; public OrdercompilerController(){ OrderNumberList= new List<String>(); compilerId= ApexPages.currentPage().getParameters().get('id'); // oc = new Order_Compiler__c(); // try{ // oc = [ SELECT Name, Account__r.Parent.Distribution_Center__c, Account__r.Parent.Address__c,Account__r.Parent.Phone FROM Order_Compiler__c Where Id =: compilerId LIMIT 1]; List<Delivery__c> del = new List<Delivery__c> (); del = [SELECT id , Name From Delivery__c WHERE Compiler__c =: compilerId]; //List<String> OrderNumberList = new List<String>() ; for( Delivery__c d : del){ OrderNumberList.add(d.Name); } //compiler = [SELECT id FROM Order_Compiler__c WHERE id =:compilerId LIMIT 1]; allItems= [SELECT Pro__c, UOM__c,SUM(Quantity__c)Qty FROM Item_Distributed__c WHERE compilerId__c =: compilerId GROUP BY Pro__c, UOM__c HAVING SUM(Quantity__c) >0 ORDER BY Pro__c, UOM__c limit 100000]; // } //catch(Exception e) //{ // System.debug(e.getMessage()); // } } } // VF Page <apex:page renderAs="pdf" readOnly="true" showHeader="false" sidebar="false" standardStylesheets="false" Standardcontroller="Order_Compiler__c" extensions="OrdercompilerController" applyBodyTag="false" > <div class="head"> <div class="col logo"> <apex:image url="{!$Resource.LogoFFP}" width="140" height="60"/> </div> <div class ="col name"> <h2> FOOD FOR THE POOR </h2> <h6> <!-- {!oc.Account__r.Parent.Distribution_Center__c} {!oc.Account__r.Parent.Address__c }--> <!-- Tels: {!oc.Account__r.Parent.Phone}--> </h6> </div> </div> <div class="footer"> <div> Printed by : {!$User.FirstName} {!$User.LastName} <apex:outputtext value="{0, date, long}"> <apex:param value="{!NOW()}"></apex:param> </apex:outputtext> at {!TIMENOW()} GMT <br/> As often as you did it for one of my least brothers, you did it for me. Matthiew 25:40 <br/> <div>Page <span class="pagenumber"/> of <span class="pagecount"/></div> </div> </div> <h3> TRANSPORT FOR: {!Order_Compiler__c.Account__r.Name } </h3> <h6>List of Order Number: </h6> {!OrderNumberList } <table style="width:100%;border-collapse: collapse; border: 0px solid black; line-height:1.1em; "> <th>Product</th> <th>Unit Of Measure </th> <th>Quantity </th> <apex:repeat value="{!allItems}" var="a"> <!-- <div class="tablebody"> --> <tr> <td>{!a['Pro__c']}</td> <td>{!a['UOM__c']}</td> <td>{!TEXT(a['Qty'])}</td> </tr> </apex:repeat> </table> </apex:page>
The best way to narrow down where the data is getting lost is to add system. debug statements in your apex code and VF page in each method.
Also see similar scenarios https://developer.salesforce.com/forums/?id=906F000000097zuIAA
https://developer.salesforce.com/forums/?id=9060G0000005aPhQAI
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you