pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dr. Stefano Sancese" <stef...@sancese.com>
Subject ListButton - Is it the correct way?
Date Mon, 02 Aug 2010 15:19:50 GMT
Hi to all,

in a form, I have a ListButton that I need to populate with 1000 
customers data (Id, Name, Address).

I wrote this class:

class lbtCustomer {
             private String id;
             private String name;
             private String address;

             lbtCustomer(String c1, String c2, String c3) {
                 id = c1;
                 name = c2;
                 address = c3;

             public String getKey() {
                 return id;

             public String toString() {
                return name + " - " + address;

and I populated the ArrayList of the ListButton with:

ArrayList lbtValues = new ArrayList();

     lbtCustomer r1 = new lbtCustomer("1","John Doe","New York");;
     lbtCustomer r2 = new lbtCustomer("8","Charlie Brown","Los Angeles");
     lbtCustomer r3 = new lbtCustomer("2","Donald Duck","Orlando");
     lbtCustomer r4 = new lbtCustomer("9","Snoopy","Los Angeles");



With the toString method I can format the information showed to the user 
and with the getKey method I can retrieve the Id of the chosen record.

The test case works, but I wonder if there is a better way.

I'm concerned about the cost (CPU and memory) associated with the 
instantiation of the 1000 objects that I need for the real case.

Perhaps two array lists: one with the data to show to the user and the 
other to store the id of the corresponding Customer?



P.s. I'm realy green to java and - YES - I'm Reading the F...... 
Manuals. There are simply too many of them ;-)

Dr. Stefano Sancese

WatchGuard Certified System Professional - http://www.watchguard.com
Socio Clusit - Associazione Italiana per la Sicurezza Informatica


In God we trust, all others we monitor (National Security Agency)


View raw message