Is there any way to pass the current value of a picklist to a controller via apex:param? I have my apex:param inside of a action:support onChange so when the user selects a picklist option it passes that value to the controller method. I'm able to pass the ID with {!$Component.FIELDID} but is there any way to pass the value for example {!$Component.FIELDID.value}? I'm unable to find much documentation on $Component.

I guess the alternative would be to use an actionFunction? I'm going to try that next but wanted to know if this way was possible.


EDIT : snippet (the inputField is a picklist)

<apex:inputField value="{!thisContact.Degree_Level__c}" id="degreeLevel">
                  <apex:actionSupport event="onchange" 
                        <apex:param name="degreeSelected" assignTo="{!degreeSelected}" value="{!$Component.degreeLevel}"/>
  • Would you please share the markup. apex:ActionSupport would have to go inside of something else. What is that something else? Is it a SelectList, InputField, something else?
    – pchittum
    Jan 24, 2013 at 16:39
  • Added code snippet.
    – Phil B
    Jan 24, 2013 at 16:41

3 Answers 3


Unless I'm missing the point of what you're trying to do, the currently selected value is accessible in the field that is bound to your inputField's value attribute.

   <apex:inputField value="{!thisContact.Degree_Level__c}" id="degreeLevel">
      <apex:actionSupport event="onchange" 

EDIT: Removed immediate attribute. Default is false.

So it should be accessible to the controller through thisContact.Degree_Level__c.

So somewhere in your controller you have a property called thisContaact and a method called updateDegreeSelected that look something like this:

public Contact thisContact{get;set;} //here is your contact property
public void updateDegreeSelected(){
//call the thisContact field in here...

  • I believe its accessible once the form is submitted but not as the user is changing the value of the picklist.
    – Phil B
    Jan 24, 2013 at 16:52
  • 1
    I've seen this with partial page refreshes, and used actionRegion to surround the portion of the form to be posted back. I've amended my answer. You need to be careful with actionRegion as anything outside of it will not be posted back to the server. So make sure that everything that does need to get back is inside of it. You can place it anywhere inside of your apex:form tag.
    – pchittum
    Jan 27, 2013 at 23:25
  • 1
    I think you need to remove the immediate="true", so that it defaults to false or change it to immedate="false" otherwise the property in the controller won't be set to the changed value. Jan 27, 2013 at 23:52
  • 1
    You're right...I looked at that last night, but it didn't sink in. Immediate true means no data passed to controller. Thanks other Peter. :-)
    – pchittum
    Jan 28, 2013 at 9:42

I will not prefer apex param.


The select list option and select list visualforce tag is made for the picklist values .Using this in controller we get selected value

  • Agree with mohit.the advantage here is that the values also get automatically bonded with the variable in you class Jan 24, 2013 at 16:36
  • I am using a selectList. I added a code sample. I want to be able to pass the value the user has selected without submitting the form so I can essentially have a dependent picklist.
    – Phil B
    Jan 24, 2013 at 16:42

You can do something like this -

<apex:inputField value="{!thisContact.Degree_Level__c}" id="degreeLevel" 

 <apex:actionFunction name="assignDegreeLevel" action="{!updateDegreeSelected}" 
   reRender="program" immediate="true">
      <apex:param name="degreeSelected" assignTo="{!degreeSelected}" value=""/>

It would work..

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .