+ Start a Discussion
rsoesemannrsoesemann 

Select rows in PageBlockTable when using ApexPages.StandardSetController

I thought it would be a simple task to add a checkbox for multiple operations to each row of a Pageblocktable. Especially when I found out that the StandardSetController which I use to back my table has a selected variable.

 

But then I found no code on how to use that. Only posts telling that for select tables I would have to create a Wrapper class around my object to store the Boolean selected.

 

The problem is I cannot use a List<WrapperSObject> as my table is backed by a StandardSetController's getRecords.

 

 <apex:pageBlockTable value="{!standardSetController.records}" var="object">
    <apex:column >
         <apex:inputCheckbox value="{!WHAT TO PUT IN HERE?]}" />
    </apex:column>
...

 So what should I bind my checkbox with.

 

Can I use the StandardSetControllers getSelected() setSelected() methods?

 

Or could I use a Map and dynamic binding like this?

 

Controller:

...

	public Map<Id, Boolean>	selection {get; set; }
...

Page:

 <apex:pageBlockTable value="{!sfdcPaginator.records}" var="object">
    <apex:column >
         <apex:inputCheckbox value="{!selection[object.Id]}" />
    </apex:column>
...