You need to sign in to do that
Don't have an account?
Mike_M_2
Can't Pass visualforce parameter to controller. 5 line example
It's very simple. I need my visualforce page to pass a string literal constant to my controller extension.
The debug log shows the value is null.
The VF page ... <apex:page standardController="Opportunity" extensions="OpportunityActualList" sidebar="false" showHeader="false"> <apex:form > <apex:pageBlock > <apex:param name="val" value="abc" /> </apex:pageBlock> </apex:form> </apex:page> The controller... public class OpportunityActualList { public string passValue{get; set;} public OpportunityActualList(ApexPages.StandardController controller){ passValue = Apexpages.currentPage().getparameters().get('val'); system.debug('passValue:' + passValue); } }
The debug log shows the value is null.
Please look the below code :
VF page:
<apex:page standardController="Opportunity" extensions="OpportunityActualList" sidebar="false" showHeader="false">
<apex:form >
<apex:pageBlock >
<apex:param name="val" value="{!abc}" />
</apex:pageBlock>
</apex:form>
</apex:page>
- In vf page there is the mistake in row 5 you are missing the {! } expression
Apex class:
public class OpportunityActualList {
public string passValue{get; set;}
public string abc{get;set;}
public OpportunityActualList(ApexPages.StandardController controller){
passValue = Apexpages.currentPage().getparameters().get('val');
system.debug('passValue:' + passValue);
}
}
- In class you have to make getter setter of abc also,
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi