[SalesForce] passing the Check box value to the apex controller

User can select or deselect a record from a list of records in a table for update by checking and unchecking of a checkbox.

I am trying to maintain this check box value in a wrapper to identify weather it is checked or not, but due to some reason my code is not displaying the check box if I add it using the apex syntax so I am using an input tag like this:

<apex: repeat value="{!WrapperList}" var="rec">
  <input type="checkbox" id="chkbx"/> 
</apex:repeat>

instead of using the following code:

<apex: repeat value="{!WrapperList}" var="rec">
  <apex:inputCheckbox value={!rec.selected}" id="select"/>
</apex:repeat>

Here my question is how can I pass the checkbox values to the wrapper class list.

Best Answer

You can collect the values of checkboxes into a string using Javascript or similar, and then pass those back to the controller, but there's no reason why your second snippet of code shouldn't work. That would be the far easier way of doing things so your best bet is to debug that.

Check if the selected property in the wrapper is public and has a public setter, then if so, look at the source generated for the page to see if the checkbox is being hidden by some CSS voodoo or similar.

Related Topic