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.


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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.