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
anup ramanup ram 

problem in assigning the total to wrapperclass property.

Hi All,

 I am facing a problem in assigning the total to wrapperclass property.

 

I have a pageblocktable with displays a pist of product with price. The quantity is entered. The total amount is calculated by calling a method in controller. But I am not bale to assign the total to that perticular row so that I am not able to display proper total on the pageblocktable.

 

please tell how to associate the total to wrapper class ..

 

Apex:

 

public class pricefromproduct

{

// where name like '%searchkey%'    select Id from product2 where name like '%searchkey%'

public pricefromproduct()

{

 

}

public integer total{get;set;}

public string searchkey {get;set;}

public list<pricewrapper> prwrp {get;set;} {prwrp = new list<pricewrapper>();}

// public list<productlist> prod{get;set;} {prod = new list<productlist>();}

public pagereference priceproduct()

{

 list<product2> prod = [select id from product2 where name like :'%'+searchkey+'%'];

 system.debug('prod size' + prod.size());

// prolist = [select id,name from product__c where name like : '%'+searchkey+'%'];

 

list<pricebookentry> pricebk = [Select Id, Name, ProductCode, Pricebook2Id, UnitPrice From PricebookEntry where Product2Id in :prod and usestandardprice = false and isactive = true];

  /*  best way to remove duplicates from list

  list<string> pr = new list<string>{'james','smith','james'};

  set<string> myset = new Set<string>();

List<string> result = new List<string>();

myset.addAll(pr);

result.addAll(myset);

system.debug(' pr size before filter ' + pr.size() + '   after ' + result.size());

*/

system.debug('pricebook size' + pricebk.size());

for (pricebookentry pb : pricebk)

{

pricewrapper p = new pricewrapper();

p.prc = pb;

p.prodprice = integer.valueof(pb.unitprice);

p.prodname = pb.name;

 

prwrp.add(p);

}

return null;

}

 

public integer f{get;set;}

public integer q{get;set;}

public pagereference totalcount()

{

f = integer.valueof(Apexpages.currentPage().getParameters().get('f'));

q = integer.valueof(Apexpages.currentPage().getParameters().get('q'));

total = f * q;

system.debug(' total ' + total);

 

 

return null;

}

 

 

 

public class pricewrapper

{

public pricebookentry prc{get;set;}

public integer prodprice{get;set;}

public string prodname{get;set;}

public boolean issel {get;set;}

public integer quantity{get;set;}

public integer totalamount{get;}

     

  public pricewrapper()

{

 

}

}

 

}

 

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
anup ramanup ram

I solved this by assigning the total to wrapperclass .

All Answers

kranjankranjan

Hi Anup,

 

Can you please share the VF code for reference.

 

Regards

anup ramanup ram

I solved this by assigning the total to wrapperclass .

This was selected as the best answer
kranjankranjan

Sounds good Anup. :)