You need to sign in to do that
Don't have an account?
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.
22 | MCDU | THALES AVIONICS SA | C19266DA01 |
22 | MCDU | THALES AVIONICS SA | C19266DA01 |
22 | RUDDER TRIM CONTROL SWITCH | GOODRICH ACTUATION SYSTEM SAS | 27-457 |
22 | RUDDER TRIM INDICATOR | ECE EQUIPEMENT and CONSTRUCTION ELEC S | 196PN01Y02 |
23 | VHF/COMM.TRANSCEIVER | HONEYWELL INTL INC DBA AEROSPACE ELE | 064-50000-0505 |
23 | VHF/COMM.TRANSCEIVER | HONEYWELL INTL INC DBA AEROSPACE ELE | 064-50000-0505 |
23 | VHF/COMM.TRANSCEIVER | HONEYWELL INTL INC DBA AEROSPACE ELE | 064-50000-0505 |
23 | RADIO MANAGEMENT PANEL | THALES AVIONICS SA | C12848CA01 |
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
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
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