[SalesForce] Apex param not passing the value – in action support event on click

I have a method to get the param value :

public PageReference facultyid() {
  public String fid{get;set;}    
  System.debug('facultyId: ' + fid);  
  return null;
}

My page calls and sets this function as below:

<apex:pageBlockTable value="{!faculties}" var="f"  id="fblock" rendered="{!faculities.size!=null}">
  <apex:column >
    <apex:actionregion >   
      <apex:outputpanel id="plusimage">
        <apex:image url="{!$Resource.Plus_Image}" onclick="switchMenu('{!$Component.inlinetablesec}','{!$Component.minusimage}','{!$Component.plusimage}')" title="Expand - Faculties"> 
          <apex:actionsupport event="onclick" action="{!facultyid}">
            <apex:param name="facultyid"  value="{!f.id}" assignTo="{!fid}" />
          </apex:actionsupport>
        </apex:image>
      </apex:outputpanel>  
    </apex:actionRegion> 

So it should pass the "fid" value immediately, but it is not happening… its showing me null value in debug logs why is it so? am i doing something wrong here, please help me to get the value of fid to controller, i can't use action function as its inside the output panel between tables, so please suggest me. Thanks in advance for the help.

Best Answer

Param will be passed on post of form to server.

In your action support you don't have any rerender attribute. Add a rerender attribute and give id plusimage.

One more thing to note is apex:param behaves differently when passing id value with string literal in name attribute.

If you change this

<apex:param name="facultyid" value="{!f.id}" assignTo="{!fid}"/>

To

<apex:param name=" {!f.id} " value="{!f.id}" assignTo="{!fid}"/>

it works. Its not documented anywhere but usually works for me.

Hope it helps.