[SalesForce] passing checkbox parameter to controller not working

Following your input I made changes but it is still not working.
This is my new code:

<apex:column >
    <apex:inputCheckbox value="{!myRec.isPerf}" id="perf">
    <apex:actionSupport event="onchange" action="{!togglePerf}" rerender="theBlock">
           <apex:param name="perfId" assignto="{!selectedItemId}" value="{!myRec.Id}"/>
    </apex:actionSupport>
    </apex:inputCheckbox>
</apex:column> 


public ID selectedItemId {get; set;}

public void togglePerf(){
      Wrapper wrapper = mapIdWrapperItem.get(selectedItemId);
}

Please advise…

Original message:

I have a column with an apex:inputCheckbox component in it.
On change I want to execute some controller logic which needs to know the value of a parameter on the page.
When the controller method is called I see the parametr is null although I know that in the page it has a value.
Can anyone suggest why this is not working and what is the right way to do this?

This is my VF code

<apex:column >
   <apex:facet name="header">Performing</apex:facet>                                            
   <apex:inputCheckbox value="{!myRec.isPerf}" id="perf">
       <apex:actionSupport event="onchange" action="{!togglePerf}" rerender="theBlock"/>
       <apex:param name="perfId" value="{!myRec.Id}"/>
   </apex:inputCheckbox>
</apex:column>

Controller code where selId is always null:

public void togglePerf(){
    String selId = System.currentPagereference().getParameters().get('perfId');
    ItemWrapper wrapper = mapIdWapperItem.get(selId);
}

Best Answer

Well seems to be a basic syntax mistake. We generally wrap the param component inside a parent action component.

Something like

<apex:actionSupport event="onchange" action="{!togglePerf}" rerender="theBlock">
    <apex:param name="perfId" value="{!myRec.Id}" />
</apex:actionSupport>
Related Topic