You need to sign in to do that
Don't have an account?
Pat Wimsatt
passing parameters
I am trying to pass a parameter to a controller. I have this block in my page:
<apex:outputText>
<apex:param name="thisParam" assignTo="{!CityO}" value="{!$CurrentPage.parameters.oCity}" />
</apex:outputText>
Then my controller has this:
public class LaneDetailCon {
public static String CityO { get; set; }
public PageReference setParams()
{
return null;
}
static List<Lane_Detail__c> lanes { get; set; }
public static List<Lane_Detail__c> getLanes()
{
System.debug('The origin city is ' + CityO);
There are no errors, thus the code executes, however, my paramater OCity returns as null. What does the apex:param action not pass the variable to OCity?
<apex:outputText>
<apex:param name="thisParam" assignTo="{!CityO}" value="{!$CurrentPage.parameters.oCity}" />
</apex:outputText>
Then my controller has this:
public class LaneDetailCon {
public static String CityO { get; set; }
public PageReference setParams()
{
return null;
}
static List<Lane_Detail__c> lanes { get; set; }
public static List<Lane_Detail__c> getLanes()
{
System.debug('The origin city is ' + CityO);
There are no errors, thus the code executes, however, my paramater OCity returns as null. What does the apex:param action not pass the variable to OCity?
Greetings!
The code looks fine to me.However,I would suggest you to have a look at the simple example to pass parameters from VF page to Controller.
https://www.xgeek.net/salesforce/the-usage-of-apexparam-in-visualforce-page/
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
All Answers
Greetings!
The code looks fine to me.However,I would suggest you to have a look at the simple example to pass parameters from VF page to Controller.
https://www.xgeek.net/salesforce/the-usage-of-apexparam-in-visualforce-page/
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
This is now my apex:page
<a href="javascript:jsActionFunction('Cincinnati');">Send Param To Apex</a> <br />
<apex:outputPanel id="vfParamPanel">
The value of parameter is : {!$CurrentPage.parameters.oCity}
</apex:outputPanel>
<apex:actionFunction name="jsActionFunction" action="{!doActionFunction}" reRender="vfParamPanel">
<apex:param name="vfParam" value="{!$CurrentPage.parameters.oCity}" assignTo="{!vfParam}"/>
</apex:actionFunction>
My controller now:
public class LaneDetailCon {
public String vfParam { get; set; }
public LaneDetailCon(){
}
public PageReference doActionFunction(){
// Do Something...
System.debug('The origin city is ' + vfParam);
return null;
}
}