1

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);
}
2

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>
0
<apex:param name="perfId" value="{!myRec.Id}" assignTo="perfId1"/>

and use get the variable through

String selId = System.currentPagereference().getParameters().get('perfId1');
  • Please add some useful information to your answer. – Sergej Utko Dec 12 '13 at 9:15
  • In his code i gotta see like he forgot to place assignto attribute – Sunny Dec 12 '13 at 12:24
0

You can easily do this by the following way:

<apex:param name="perfId" value="{!myRec.Id}" assignTo="{!perfId1}"/>

and create a similar variable in the controller.

String perfId1;
system.debug(perfId1); // this will print the value
0

Everything I tried failed so I ended taking the action support out and used apex:actionFunction like this:

 <apex:actionFunction name="toggleMMcheckboxJS" action="{!toggleMMcheckbox}" id="actionFunc1" status="assign-action-status" rerender="theRelatedCatalogItemsBlock">
        <apex:param name="selectItemId" value=""/> 
        <apex:param name="selectLevel" value=""/> 
        <apex:param name="selectStatus" value=""/>          
    </apex:actionFunction>


<apex:column headerValue="Select">
    <apex:facet name="header">World Class</apex:facet>                                            
    <apex:inputCheckbox onclick="toggleMMcheckboxJS('{!mapIdWithMaturityModelRelatedItem[currentRecord].Id}', 'WC', '{!mapIdWithMaturityModelRelatedItem[currentRecord].isWorldClass}');" 
                                                selected="  {!mapIdWithMaturityModelRelatedItem[currentRecord].isWorldClass}" id="wc"/>                                                    
</apex:column>





public Pagereference toggleMMcheckbox(){
    String selId = ApexPages.currentPage().getParameters().get('selectItemId');
    String selMaturityLvl = ApexPages.currentPage().getParameters().get('selectLevel');
    //the current value before change
    Boolean selStatus = Boolean.valueOf(ApexPages.currentPage().getParameters().get('selectStatus'));

    try{                            

    }   
    catch(Exception e){
        system.debug(LoggingLevel.ERROR, e);
    }

    return null;                                    
} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.