You need to sign in to do that
Don't have an account?
issue with apex:page action
Hi,
I have a Visualforce page that calls init() function at the page level like below:
<apex:page standardController="Volunteer_Activity__c" action="{!init}" title="Volunteer Activity: {!Volunteer_Activity__c.Name}" extensions="VolActivityMassSignUpControllerExt">
In my controller init() function when I try to get an attribute (Total_Number_of_Participants__c) of the Volunteer_Activity object, I get a null. Here is how my controller class looks like:
public class VolActivityMassSignUpControllerExt {
private Volunteer_Activity__c va;
public VolActivityMassSignUpControllerExt(ApexPages.StandardController stdController) { this.va = (Volunteer_Activity__c) stdController.getRecord();
System.debug(Logginglevel.DEBUG, 'Constructor ' + va.Id);
}
public void init() {
id = va.Id;
name = va.Name;
Double totalParticipants = va.Total_Number_of_Participants__c;
---
---
}
}
To resolve this, I am explicitly doing a query to retrieve the object. Did anyone experience this issue? Can you please help?
Thanks,
Geeta
First of all, directly from the documentation for the action attribute on apex: page:
You are saying that your Total_Number_of_Participants__c has a value at load time, and your id and name are non null but the number of participants is null? That seems strange.
Regardless the first thing you need to do is get rid of your page level action and instead call init() inside of your extension constructor. I doubt this will get rid of your issue but it's good practice anyway. What references do you have on your page to the Total_Number_of_Participants field?
All Answers
First of all, directly from the documentation for the action attribute on apex: page:
You are saying that your Total_Number_of_Participants__c has a value at load time, and your id and name are non null but the number of participants is null? That seems strange.
Regardless the first thing you need to do is get rid of your page level action and instead call init() inside of your extension constructor. I doubt this will get rid of your issue but it's good practice anyway. What references do you have on your page to the Total_Number_of_Participants field?
Thanks Jill. I changed it as per your suggestion and it works fine now.