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
manuel.garciamanuel.garcia 

Pass an argument in an action method

Hi,

I would like to know if it is possible to pass an argument in an action method.

 

I want to pass a concrete string when button is pushed.

 

My code is:

 

**APEX**


[...]

<apex:column value="{!a.phone}"/>
      <!-- BOTON EN UNA COLUMNA NUEVA -->
      <apex:column headerValue="ClickToCall">
      <apex:form >
      <apex:commandButton value="LLamar" action="{!clickToCall}"/>
      </apex:form>
      </apex:column>

[...]

 

--> I WANT TO DO SOMETHING LIKE THIS: clickToCall({!a.phone})

 

**CONTROLLER CLASS**

 

public PageReference clickToCall(String number)
    {

       *DO SOMETHING*...
    }

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You can't pass the argument to the action method itself, as those cannot take parameters.  The way it works is that you supply the param as Shash has shown, and then by the time the action method is invoked, the associated controller property has been populated with the data.

 

I wrote a blog post on this at:

 

http://bobbuzzard.blogspot.com/2011/07/passing-parameters-to-apex-method-from.html

All Answers

Shashikant SharmaShashikant Sharma

Yes try this

 

<apex:commandButton value="LLamar" action="{!clickToCall}">
<apex:param name="stringParameterText " value="string to pass" />
</apex:commandButton>

 

let me know if any issues in it.

bob_buzzardbob_buzzard

You can't pass the argument to the action method itself, as those cannot take parameters.  The way it works is that you supply the param as Shash has shown, and then by the time the action method is invoked, the associated controller property has been populated with the data.

 

I wrote a blog post on this at:

 

http://bobbuzzard.blogspot.com/2011/07/passing-parameters-to-apex-method-from.html

This was selected as the best answer
manuel.garciamanuel.garcia

It works, thx you so much :)