VF Page component class Not getting value of soID.query works if i pass hard coded ID.Please someone tell me where i am wrong..**The constructor gets called first, before any variables are set. I dont know how to do this…
public with sharing class saleslinecntlr {
public string soID{get;set;}
List<Sales_Order_Line__c> saOrderLin;
public saleslinecntlr ()
{
System.debug('---------'+soID);
saOrderLin=[Select id,name,Product__r.Name,Serial_Number__c,Quantity__c,Sale_Price__c,Total__c
from Sales_Order_Line__c where salesorderid=:**soID** order by name];
}
public List<Sales_Order_Line__c> getsaOrderLin() {
return saOrderLin;
}
}
Best Answer
Component constructors are called before the property setters, this is not only the way things are with VF components but with Apex classes in general. The usual workaround to this is to apply your logic in the getsaOrderLin method instead, try this...