Home arrow static arrow Java Programming [Archive] - Creating a Table (not SWING or AWT)
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Creating a Table (not SWING or AWT)
This topic has 1 reply on 1 page.

Posts:15
Registered: 10/23/01
Creating a Table (not SWING or AWT)  
Jun 17, 2004 11:15 AM



 
Hello Everyone,

I'm trying to come up with a design to create a table grid in pure java that will be displayed on my web page. This is a 2-dimensional table that will have rows and columns. The data for each cell is retrieved from a mySQL table.
Here's where it gets sticky. The users of my web page can enter a product number. Based on that number I'm returning a combination of sizes and colors for that product. To populate the table I need to call 3 different tables.
My first table is SIZE
My second table is COLOR
My third table is DETAILS

The DETAILS table has two fields: Color and Size. If the Color and Size field match up against the COLOR and SIZE tables then create a cell for that combination.

Here's the logic I've come up with so far:
Loop through SIZE.
Loop through COLOR.
Loop through DETAILS.
if color and size field of table DETAILS equals the size or color of the table SIZE and COLOR then create a new cell.

It should look something like this:

Hello Everyone,

I'm trying to come up with a design to create a table grid in pure java that will be displayed on my web page. This is a 2-dimensional table that will have rows and columns. The data for each cell is retrieved from a mySQL table.
Here's where it gets sticky. The users of my web page can enter a product number. Based on that number I'm returning a combination of sizes and colors for that product. To populate the table I need to call 3 different tables.
My first table is SIZE
My second table is COLOR
My third table is DETAILS

The DETAILS table has two fields: Color and Size. If the Color and Size field match up against the COLOR and SIZE tables then create a cell for that combination.

Here's the logic I've come up with so far:
Loop through SIZE.
Loop through COLOR.
Loop through DETAILS.
if color and size field of table DETAILS equals the size or color of the table SIZE and COLOR then create a new cell.

It should look something like this:

� ����������� Small Medium Large

Black | � � ok � � ok � ��� <blank>

Blue � | � � ok � � <blank> � � ok

Red � | � � ok � � <blank>��<blank>

I created 3 different Java classes. The classes are Table, Row, Cell. The Table class has a bean setter/getter array: private Row[] rowDetails; The Row class has setter/getter details about each individual cell: private Cell[] sizes; The Cell class holds the details like quantityAvailable. I'm struggling with this one on the logic and how to loop through each element.

I think this is the right approach but I'm not sure. I was hoping that someone can help me out with the logic.

Thank you!!

 

Posts:15
Registered: 10/23/01
Re: Creating a Table (not SWING or AWT)  
Jun 17, 2004 11:18 AM (reply 1 of 1)



 
Sorry, the formatting for the table came out pooly.

The headers are the size and on the left side it should be the color. an OK means that a combination exists and a <blank> means that there's no such combination. In that case I should skip over the cell and proceed to the next one.

Small Medium Large

Black | ok ok <blank>

Blue | ok <blank> ok

Red | ok ok ok
 
This topic has 1 reply on 1 page.