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
SjaleelSjaleel 

Wrapper Class

Dear Developers,

 

Can anyone enlighten how a wrapper really work?  I am creating a VF page for custome objects as detailed spec sheet, the object has a table list of with several items in it. Each item has got serail no, product no , desceription and so on. Some of the items are listed more than once and they just differ in serial number but the other are all the same. When displaying in the actual VF page I dont need the item to be repetead but total count of each item with.

 

22MCDUTHALES AVIONICS SAC19266DA01
22MCDUTHALES AVIONICS SAC19266DA01
22RUDDER TRIM CONTROL SWITCHGOODRICH ACTUATION SYSTEM SAS27-457
22RUDDER TRIM INDICATORECE EQUIPEMENT and CONSTRUCTION ELEC S196PN01Y02
23VHF/COMM.TRANSCEIVERHONEYWELL INTL INC DBA AEROSPACE ELE064-50000-0505
23VHF/COMM.TRANSCEIVERHONEYWELL INTL INC DBA AEROSPACE ELE064-50000-0505
23VHF/COMM.TRANSCEIVERHONEYWELL INTL INC DBA AEROSPACE ELE064-50000-0505
23RADIO MANAGEMENT PANELTHALES AVIONICS SAC12848CA01



 

As you can see the table its repeting the items but i'd rather display them once in the table and show its quantity, is that possible if so how?

 

Thanks and regards

S.Aj

 

SrikanthKuruvaSrikanthKuruva

i suppose the records shown below are in some list say

List<somedataype> livar;

now create a new class inside the actual class

public class innerClass

{

integer count;

somedatatype sdt

}

List<innerClass> liinnerclass = new List<innerClass>();

now loop over the list livar

for (somedatatype var : livar)

{

use the 'var' and how many times it repeats in 'livar' - to do this you will need one more for loop over'livar' -and as and when you are finding matching records delete them from livar to avoid duplicat counting

 

after counting do this

innerClass ic = new innerClass();

ic.count = //the count which we get in the above counting

ic.sdt = var

liinnerclass.add(ic);

}

 

the inner class which we have created here is nothing but the wrapper class

SjaleelSjaleel

Thanks for reply..but still got one question

 

How is inner loop done, loop over'livar' ? How can it be traversed, what are the conditon set for the looping? Do we use the List size for it?

 

 

 

Regards and thanks in advance

S.Aj