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
bingi crm 7bingi crm 7 

i am writting a wrapper class they showin bug i am write the instace of object wrapper1 but they are showing error

public class Displayprods1
{
public List<OpportunityLineItem> proList{get;set;}
public list<wrapper1> wrp{get;set;}
List<OpportunityLineItemwrapper> OppList = new List<OpportunityLineItemwrapper>();
public Displayprods1(ApexPages.StandardController controller)
{
}
public void populate(){
list<OpportunityLineItem > plist = [select id,Quantity,ListPrice,TotalPrice from OpportunityLineItem limit10];
for(OpportunityLineItem pr:plist){
wrapper1 w1 = new wrapper1();
w1.name = pr.name;
w1.Quantity = pr.Quantity;
w1.ListPrice = pr.ListPrice;
w1.TotalPrice = pr.TotalPrice;
wrp.add(w1);
}
}
}
-------------------------------------------------------------------
wrapper class
public class OpportunityLineItemwrapper
{
// all the line record instance create
public OpportunityLineItem pro{get; set;}
public string name {get;set;}
public integer Quantity {get;set;}
public decimal ListPrice {get;set;}
public decimal TotalPrice {get;set;}
 public Boolean selected {get; set;}
 public OpportunityLineItemwrapper() { name = ''; Quantity = 0 ; ListPrice = 0 ; TotalPrice = 0;
}
}
Amit Chaudhary 8Amit Chaudhary 8
NOTE:- your wrapper class name is OpportunityLineItem  not wrapper1
Try to update your class like below
public class Displayprods1
{
	public List<OpportunityLineItem> proList{get;set;}
	List<OpportunityLineItemwrapper> OppList  {get;set;}
	public Displayprods1(ApexPages.StandardController controller)
	{
		OppList = new List<OpportunityLineItemwrapper>();
	}
	public void populate()
	{
		list<OpportunityLineItem > plist = [select id,Quantity,ListPrice,TotalPrice from OpportunityLineItem limit10];
		for(OpportunityLineItem pr:plist)
		{
			OpportunityLineItemwrapper w1 = new OpportunityLineItemwrapper();
			w1.name = pr.name;
			w1.Quantity = pr.Quantity;
			w1.ListPrice = pr.ListPrice;
			w1.TotalPrice = pr.TotalPrice;
			OppList.add(w1);
		}
	}
}

Let us know if this will help you

Thanks
Amit Chaudhary
bingi crm 7bingi crm 7
hit the error on the quantity lllegal assignment from Decimal to Integer
Amit Chaudhary 8Amit Chaudhary 8
public class Displayprods1
{
	public List<OpportunityLineItem> proList{get;set;}
	List<OpportunityLineItemwrapper> OppList  {get;set;}
	public Displayprods1(ApexPages.StandardController controller)
	{
		OppList = new List<OpportunityLineItemwrapper>();
	}
	public void populate()
	{
		list<OpportunityLineItem > plist = [select id,Quantity,ListPrice,TotalPrice from OpportunityLineItem limit10];
		for(OpportunityLineItem pr:plist)
		{
			OpportunityLineItemwrapper w1 = new OpportunityLineItemwrapper();
			w1.name = pr.name;
			w1.Quantity = Integer.valueOf(pr.Quantity);
			w1.ListPrice = pr.ListPrice;
			w1.TotalPrice = pr.TotalPrice;
			OppList.add(w1);
		}
	}
}
Let us know if this will help u
 
bingi crm 7bingi crm 7
i am try to display this values on vf page i am write a code but they are not showing the values
bingi crm 7bingi crm 7
Unknown property 'OpportunityStandardController.OppList'