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
vreddyvreddy 

<apex:param> assignTo seems not working...simple code

Hi all,

 

I am facing problem having <apex:param assignTo...> working with <CommandButton>.  So started with this simple code to test. It is not working. Can somebody please let me know where I am going wrong? Appreciate Your help.

 

And the most important thing is : The Values are successfully printed on the page but unable to pass back to Controller !!!

 

Thanks!

 

VisualForce Code:

 

<apex:page controller="MyController" >
<apex:form >
    <apex:commandButton action="{!doLoginCommand}" value="Click" >
        <apex:param name="sessionId" assignTo="{!apiSessionId}" value="{!$Api.Session_ID}" />
        <apex:param name="serverURL" assignTo="{!apiServerURL}" value="{!$Api.Partner_Server_URL_140}" />
    </apex:commandButton>

    Session ID : {!$Api.Session_ID}<br/>
            URL: {!$Api.Partner_Server_URL_140}
</apex:form>
</apex:page>

 

 

Controller:

 

public class MyController {
     public String apiSessionId {get;set;}
     public String apiServerURL {get;set;}

 public pageReference doLoginCommand(){
        System.debug('Inside the Method ');
        System.debug('api SessionId: ' + apiSessionId);
        System.debug('api ServerURL: ' + apiServerURL);
    return null;
 }
}

 

 

Debug Log:

 

18.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;VALIDATION,INFO;WORKFLOW,INFO
11:15:25.586|EXECUTION_STARTED
11:15:25.587|CODE_UNIT_STARTED|[EXTERNAL]VF-Outer
11:15:25.590|CODE_UNIT_STARTED|[EXTERNAL]VForcePage
11:15:25.590|METHOD_ENTRY|[12,2]|System.debug(String)
11:15:25.590|USER_DEBUG|[12,2]|DEBUG|Inside the Method
11:15:25.590|METHOD_EXIT|[12,2]|debug(ANY)
11:15:25.590|METHOD_ENTRY|[13,2]|System.debug(String)
11:15:25.590|USER_DEBUG|[13,2]|DEBUG|api SessionId: null
11:15:25.590|METHOD_EXIT|[13,2]|debug(ANY)
11:15:25.590|METHOD_ENTRY|[14,3]|System.debug(String)
11:15:25.590|USER_DEBUG|[14,3]|DEBUG|api ServerURL: null
11:15:25.590|METHOD_EXIT|[14,3]|debug(ANY)
11:15:25.590|CODE_UNIT_FINISHED
11:15:25.591|VF_APEX_CALL|j_id2|{!doLoginCommand}|PageReference: none
11:15:25.633|CODE_UNIT_FINISHED
11:15:25.633|EXECUTION_FINISHED

 

 

 

 

 

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
stephanstephan

I believe this is a known bug. As a woraround, you might instead try specifying a rerender target for the commandButton. This should allow the params to be passed back to the controller correctly.