You need to sign in to do that
Don't have an account?

How and When is the Apex constructor being instantiated?
I read that Apex constructor runs when the VF is being generated, but it doesn't not in my case
So i have this Apex code and VF code.
public with sharing class ItemsToApproveA { private final string UserID = UserInfo.getUserId(); private List<ProcessInstance> ProcessInstanceID {get; set;} public String getUserID() {return UserID;} public void ItemsToApproveA(){ ProcessInstanceID = [SELECT TargetObjectId FROM ProcessInstance Where Id IN (SELECT ProcessInstanceId FROM ProcessInstanceWorkitem Where ActorId = :UserID)]; } public List<ProcessInstance> getProcessInstance() { return ProcessInstanceID; } }
<apex:page controller="ItemsToApproveA"> <apex:pageBlock title="Items To Approve"> <apex:pageBlockTable value="{! ProcessInstance}" var="Items"> <apex:column value="{! Items.TargetObjectId}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:page>
The ProcessInstanceID variable doesn't get assign with any values, unless I move the code below into the getProcessInstance funcation :
ProcessInstanceID = [SELECT TargetObjectId FROM ProcessInstance Where Id IN (SELECT ProcessInstanceId FROM ProcessInstanceWorkitem Where ActorId = :UserID)];
The constructor doesn't return anything so shouldn't be a type
So remove the 'void' from:-
public void ItemsToApproveA()
It's good to put your complete GET logic within the GETer method - looks like you solved your problem.
As for your other question of "when does this get instanciated?" - check out the VF "Order of Execution":
http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_lifecycle_example.htm