Days of our Lives!

May 25, 2006

Of ArrayLists and MR’s and quite a lot of if’s and for’s

Filed under: work(place) — Santhosh @ 8:15 PM

An arrayList within an arrayList within an arrayList within a class which in turn is nested, so that the last class (i hope this is it!) is some 13 classes away from the starting class.
Objects spread over these and i have to display them in the form of a table…
Had coded them with nested loops, a whole mesh of if’s and for’s and arrayLists.
Problem is the columns in the table dont follow the same order as the hierarchy of the arrayLists.
So that if one of the arraylists is null, nothing will be displayed in the table (not even those that are mapped to objects not in these arrayList structure) coz the control doesnt at all come down here.
Tried to have the HTML code in between the java arrayList code.
Problem with this is since the columns are all mixed w.r.t the mapped object’s source, even if one arrayList is null, the remaining wont be displayed (even those from a higher hierarchy) coz control wont come there at all.
Thought of getting all these into 2-D array and then displaying it.
Then the problem is the number of objects in the arrayLists.
In a particular row, some columns may or may not have data to be displayed. Also for some there may be two values to be displayed.
After some serious tinkering, decided and settled upon else statements.
Have an ‘if’ condition to check for null, and if it is, code all over again with blanks in the places where it’s mapped to this arrayList and lower hierarchy arrayLists.
In the end, a whole maze of for’s, if’s, else’s….

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: