I have a requirement in which when select the checkbox based on the value of checkbox i.e. true or false, I have to pass the value to Apex class method and based on the value of checkbox it should display an status images. I have modified the code in VF page like this:

    j$('.voCheckbox').click(function() {
<apex:actionFunction action="{!completeActionCheck}" name="completeActionJSCheck" >
     <apex:param name="v" value="" assignTo="{!myCheckbox}" /> 

VF code for setting the image based on the value of checkbox:

    <label class="outcome-name">{!output.Name}:</label>
    <apex:outputPanel layout="none" rendered="{!currentOpportunity[output.FieldName__c] == true}">

    <input type="checkbox" class="voCheckbox"  Checked="Checked" Value="true" event="onselect" style="vertical-align: middle" data-outcome="{!outcome.Id}" enable="true"/>
    <i class=" green"></i>

    <apex:outputPanel layout="none"  rendered="{!currentOpportunity[output.FieldName__c] == false}">
    <input type="checkbox" Checked="False" class="voCheckbox" event="onselect" style="vertical-align: middle" data-outcome="{!outcome.Id}" enable="true"/>
    <i class="fa fa-times red"></i>

in the above code I have used to pass the value to the Boolean variable myCheckbox. But on UI when I select/disselect the checkbox then it thows and error. "Value not of required type".

in Apex class I have modified the below code :

public boolean myCheckbox {get; set;}
ActionResult result = ActionFactory.getInstance(selectedOutputId, oppId).execute(myCheckbox);

Can somebody help me what I am missing here? My target is i

1 Answer 1


I think you should not use an actionFunction, but rather actionSupport. Your checkbox will look something like this;

<apex:inputCheckbox value="{!myCheckbox}>
    <apex:actionSupport event="onchange" action="{!myApexFunction}" />

In this case the checkbox will be automatically posted to the controller, so there's no need to pass it as a parameter. For reference; the documentation of the actionSupport element.

  • Hi @Lex when I add the below code <apex:inputCheckbox value="{!myCheckbox}"> <apex:actionSupport event="onchange" action="{!completeActionCheck}" /> </apex:inputCheckbox> then it does not load the lage because in my case based on the value of true and false I am setting the images based on page load.I have added the image code In the question. please check
    – SFDCDJ
    Aug 11, 2016 at 6:42
  • It seems to me you want to show a different image, based on the value of a chechbox. In that case you can still use actionSupport. I suggest you check the documentation, especially the part about the rerender attribute. You can also use it in conjunction with actionRegion, that would be helpful to you as well. Currently, the question is too unclear for me to provide more detailed code snippets. Aug 11, 2016 at 6:49
  • the reason I am using actionfunction because it is under the <apex:form> that's why I have to use actionFunction in this case
    – SFDCDJ
    Aug 11, 2016 at 7:12
  • An actionSupport can also be a child of a form. In fact, it has to be. Aug 11, 2016 at 8:58

You must log in to answer this question.

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