function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pat WimsattPat 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?
Best Answer chosen by Pat Wimsatt
ShirishaShirisha (Salesforce Developers) 
Hi Pat,

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

ShirishaShirisha (Salesforce Developers) 
Hi Pat,

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 was selected as the best answer
Pat WimsattPat Wimsatt
Thank you Shirisha, but it still is not returning what I expect to see.  Do you see any error?  The !doActionFunction is not being called and thus the System.debug return is not showing in the log. I have it exactly like the sample:  https://www.xgeek.net/salesforce/the-usage-of-apexparam-in-visualforce-page/


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;
    }
}