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
bestjamiebestjamie 

how to set parameter for actionfunction

I want to add some parameter for the function in actionfunction.

example:
visualforce code

<apex:actionFunction action="{!insertSelDMDocId}"  status="selDocIdCb" name="insertSelDMDocId"/>

fuction abc(){

 insertSelDMDocId();//i want to add a parameter like insertSelDMDocId(id)

}

apex code:

// I want to get id here like insertSelDMDocId(id) , but it some error occurred.
public void insertSelDMDocId() {

   myid = id

 }

i have no idea about this issue.

If anyone can help me?

Thank you very much!!

 

Best Answer chosen by Admin (Salesforce Developers) 
Rajesh ShahRajesh Shah

I think you can use param component here. Heres an example. (I have used actionSupport, but it can also be used with actionFunction)

 

<apex:actionSupport event="onclick" action="{!findDates}" reRender = "Dates ,TranscriptPanel">
<apex:param name="paramid" value="{!UserLists.UserId}"/>
</apex:actionSupport>

//////////// Heres the controller part

// Inside the function findDates()
String msgId = ApexPages.currentPage().getParameters().get('paramid')

 

 

 


Message Edited by Rajesh Shah on 10-16-2009 06:55 PM

All Answers

Ron HessRon Hess

we use an input field for this

 

 

 

<apex:inputHidden value="{!myparameter}" id="mycoolID" />

 

 somewhere on your page.

 

 

then in your javascript, you get the element and stuff a value into it.

 

here is an example of this technique 

 

http://wiki.developerforce.com/index.php/Sites_And_Captcha

 

looks like this : 

 

 

<apex:form > <apex:inputhidden value="{!challenge}" id="challenge" /> <apex:inputhidden value="{!response}" id="response" /> <script type="text/javascript"> function captureResponse(ele) { document.getElementById('{!$Component.challenge}').value = document.getElementById('recaptcha_challenge_field').value; document.getElementById('{!$Component.response}').value = document.getElementById('recaptcha_response_field').value; } </script>

 

 

now, in apex code your value is available for use

 

 

 

Rajesh ShahRajesh Shah

I think you can use param component here. Heres an example. (I have used actionSupport, but it can also be used with actionFunction)

 

<apex:actionSupport event="onclick" action="{!findDates}" reRender = "Dates ,TranscriptPanel">
<apex:param name="paramid" value="{!UserLists.UserId}"/>
</apex:actionSupport>

//////////// Heres the controller part

// Inside the function findDates()
String msgId = ApexPages.currentPage().getParameters().get('paramid')

 

 

 


Message Edited by Rajesh Shah on 10-16-2009 06:55 PM
This was selected as the best answer
bestjamiebestjamie

Thank you all. I solved this problem.

Both of above solution are greate.  I just did as you mentioned. It does work.

 

Ron HessRon Hess
Yeah, that is even cleaner than my idea.