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

can't get the apex:param to pass value to controller?

I am trying to use apex:actionFunction that has one parameter in my apex:page javascript but the parameter is always null and I cannot figure out WHY?


I created a simple test page to test what I am doing:


<apex:page standardController="Quote" extensions="QuoteLineItems_ControllerExtension">

<apex:pagemessages />
<apex:pageBlock mode="edit">
    <apex:form id="testPage_Form">
        <script language="JavaScript" type="text/javascript">  
            function test1() {
                alert('>> init TEST_PAGE <<');   
                updateTest('this is my test data');
        <apex:actionFunction name="updateTest" action="{!updateTestData}">
           <apex:param name="test_param1" value="TEST_DUMMY" />
        <input type='button' value='TEST 1' onclick='test1();'/>


Here is a method in my the controller:


    public PageReference updateTestData() {
        System.Debug('>>> updateTest <<<');
        String test_param1 = ApexPages.CurrentPage().getParameters().get('test_param1');
        System.Debug('>>> test_param1 = '+ test_param1 + ' <<<');
        return null;


Debug Log returns:

    >>> updateTest <<<

    >>> test_param1 = null <<<         ?? WHY NULL, expecting 'this is my test data'


WHAT am I doing wrong?


The work arround Shamil linked works for me, but can it really be the case, that the assignTo on apex:param still doesn't work with commandButtons? anyone know if there has happend anything on this since 2009?




you need a rerender on the commandbutton for it to pass the parameter to the controller.


try this


  <apex:actionFunction name="updateTest" action="{!updateTestData}" reRender="">

           <apex:param name="test_param1" value="" />





pradeepkumar danipradeepkumar dani
@Vidula -- It works... Thanks

ReRender tag is must itseems. My work around was to use ReRender="" & use oncomplete="'{!customURL},'_parent');"
Vanessen.. thank you for your comment.. I was not passing the param to the class and when I added the rerender it now passes..  Only issue I have not is that the page it not rerendering.  thanks!