function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dai developerdai developer 

Parameters

Hello,

I have a wrapper, <opportunity opp, boolean selected>

I iterate a list of wrapped opps build like this

checkbox - opportunity A
checkbox - opportunity B
checkbox - opportunity C

How can the controller get the id of the opportunity selected / unselected  ?

{var.opp.id} ??

script and apex function params ??

thanks
Best Answer chosen by dai developer
Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
It seems like you want to process a single record at a time.
I would suggest you to maintain one more list for processed records which in turn you can use to comapre and get the selected record for current click.
Process record from current click event and then add it to previously selected list.
Now when you click on new checkbox, check if that record is already in previously selected list and accordingly add it to the cureent selection list.

This will ensure that you will process only one record at a time.

-N.J

All Answers

Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
Add this to your page to bind checkbox value with opp record
<apex:inputCheckbox value="{!OppWrapper.selected}" id="checkedone">
         <apex:actionSupport event="onclick" action="{!GetSelected}"/>
</apex:inputCheckbox>
where OppWrapper is wrapper list and then get selected records in controller using
public PageReference getSelected()
    {       
        selectedOppList.clear();
        for(OpportunitySelectorWrapper selectorWrapper: oppWrapperList)
            if(selectorWrapper.selected == true)
                selectedOppList.add(selectorWrapper.opp);
                
        return null;
    }

dai developerdai developer
Thank you

That´s exactly what I have, but, this gives me 'all' the records checked, what I want to update (or not) is the record just checked / unchcked.

Did I miss anything ? 
Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
It seems like you want to process a single record at a time.
I would suggest you to maintain one more list for processed records which in turn you can use to comapre and get the selected record for current click.
Process record from current click event and then add it to previously selected list.
Now when you click on new checkbox, check if that record is already in previously selected list and accordingly add it to the cureent selection list.

This will ensure that you will process only one record at a time.

-N.J
This was selected as the best answer