1

I created an MVC software architecture. Here's the breakdown: M= Model_Enter_Discount V=Page_Enter_Discount C=Controller_Enter_Discount.

On my Model_Enter_Discount page, I have created the following 3 lists:

    public void createDifferentProductLists(String quoteID)
    {
        public List<productWrapper> nonDiscountableList = new List<productWrapper>();
        public List<productWrapper> supportDiscountList = new List<productWrapper>();
        public List<productWrapper> productDiscountList = new List<productWrapper>();
        List<QuoteLineItem> quoteLineItemList=[Select ID,Discount,Product_Code__c,Quantity,PricebookEntryId,QuoteId,Discounted_Unit_Price__c FROM QuoteLineItem Where QuoteId=:quoteID];    
        }
        List<PricebookEntry> priceBookEntryList = [SELECT ID,NAME,PRODUCT2ID,UNITPRICE FROM PricebookEntry Where ID in: PricebookEntryIDx]; 
        }
        List<Product2> product2List = [SELECT ID,NAME,DISCOUNTABLE__C,PRODUCTCODE FROM PRODUCT2 WHERE ID IN:Product2Idx];

        productWrapper fullProductList = new productWrapper();
        for(QuoteLineItem QLI: quoteLineItemList){
            fullProductList.QLTID = QLI.ID;
            fullProductList.Product_Code = QLI.Product_Code__c;
            fullProductList.Quantity = QLI.Quantity;
                fullProductList.Product2Id = PBE.Product2Id;
            fullProductList.UnitPrice = PBE.UnitPrice;
            fullProductList.Discountable = P2.Discountable__c;
        }   
        if(fullProductList.Discountable == 'No'){
            nonDiscountableList.add(fullProductList);
        }       
        else
            if(fullProductList.Product_Code.startsWith('SV')){
                serviceDiscountList.add(fullProductList);
                }
            }       
        else 
            productDiscountList.add(fullProductList);
            }                       
    }

As you can see, I use a wrapper class(name of wrapper class is productWrapper) to take fields from QuoteLineItems,PricebookEntry and Product2 to create 3 new lists.

Then, on my controller which is Controller_Enter_Discount, I call each of these lists. For this example, I'll be calling the productDiscountList.

 discountUtility = new Model_Quote_Discount();
public List<Model_Quote_Discount.productWrapper> getProductDiscountList()
{   
    return discountUtility.productDiscountList();
}    

Finally, on my visualforce page, I want to output a datatable with the contents of the productDiscountList.

    <apex:dataTable align="left" value="{!productDiscountList}" var="quo" >
      <apex:column headervalue="Quantity" value="{!quo.Quantity}"/>
      <apex:column headervalue="Product Code" value="{!quo.Product_Code}"/>
    </apex:dataTable> 

Visualforce then gives me an error saying Unknown property: Model_Enter_Discount.productwrapper.Quantity. Why is the Visualforce page unable to access the Quantity column on the list that I created on the Model side?

Wrapper class code as requested:

    public class productWrapper 
    {
        ID QLTID {get;set;}//QuoteLineItemlist ID
        Double Discount{get;set;}//QuoteLineItem Discount
        String Product_Code{get;set;}//QuoteLineItem ProductCode
        Decimal Quantity{get;set;}// QuoteLineItem Quantity
        ID PricebookEntryID{get;set;}// QuoteLineItem PricebookEntryId
        ID Product2Id{get;set;}//PricebookEntryList Product2Id
        Double UnitPrice{get;set;}// PricebookEntryList UnitPrice
        String ProductName{get;set;}// Product2List Name
        String Discountable{get;set;} //Product2List Discountable

/** Class:public class productWrapper 
        * Input:         
        * Ouput:        
        * Purpose:  
**/     
        public productWrapper()
        {
            this.QLTID=QLTID;
            this.Discount=Discount;
            this.Product_Code=Product_Code;
            this.Quantity=Quantity;
            this.PricebookEntryID=PricebookEntryId;
            this.Product2Id=Product2Id;
            this.UnitPrice=UnitPrice;
            this.ProductName=ProductName;
            this.Discountable=Discountable;
        }   
    }
}
  • 1
    can you please post your wrapper class? I think the issue is in there. – jnoel10 Aug 13 '13 at 19:34
  • Hi, I've updated the post with the wrapper class. – SSadat Aug 13 '13 at 19:36
4

The problem is in your Wrapper class, the variables are not PUBLIC, any external class will not see the variables as visible.

The changes are below:

        Public ID QLTID {get;set;}//QuoteLineItemlist ID
        Public Double Discount{get;set;}//QuoteLineItem Discount
        Public String Product_Code{get;set;}//QuoteLineItem ProductCode
        Public Decimal Quantity{get;set;}// QuoteLineItem Quantity
        Public ID PricebookEntryID{get;set;}// QuoteLineItem PricebookEntryId
        Public ID Product2Id{get;set;}//PricebookEntryList Product2Id
        Public Double UnitPrice{get;set;}// PricebookEntryList UnitPrice
        Public String ProductName{get;set;}// Product2List Name
        Public String Discountable{get;set;} //Product2List Discountable

Hope this helps.

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.