public with sharing class ControllerExtension {
   public Set<WrapperOppLineItem> shoppingCartSet {

    public class WrapperOppLineItem{
        public opportunityLineItem oppLineitem {get;set;}
        public Boolean selected {get;set;}
        public Id idValue {get;set;}

        public WrapperShoppingCart(opportunityLineItem oLineItem ){
            oppLineitem = oLineItem;
            selected = false;
            idValue = oLineItem.id;

        public Boolean equals(Object obj){
            if(obj!= null && obj instanceOf OpportunityLineItem){
                OpportunityLineItem li = (OpportunityLineItem) obj;
                if((li.id == idValue)){
                    return true;
                    return false;
                return false;



            <apex:pageblockTable value="{!shoppingCartSet}" var="s">
                    <apex:column >
                        <apex:inputCheckbox value="{!s.selected}"/>                     

It throws error saying that 'Unknown Property SetValue.selected'

Note: I did not include the complete code for controller and visualforce but just the relevant part to show the problem I have.

1 Answer 1


It looks like the collection cannot be a Set in this Visualforce context. You can add a property that converts it into a List:

public List<WrapperOppLineItem> shoppingCartList {
    get {
        return new List<WrapperOppLineItem>(shoppingCartSet);

and reference that shoppingCartList instead; that list will be referencing the same underlying WrapperOppLineItem objects.

You should also add a hashCode method to your WrapperOppLineItem if you haven't already. See e.g. Using Custom Types in Map Keys and Sets. There is a static System.hashCode method you can use on any type object including the Id type, so based on your equals, the method would be at its simplest:

public Integer hashCode() {
    return System.hashCode(idValue);

You must log in to answer this question.

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