This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have a Model that contains a Collection of Characteristic Groups. Each Characteristic Group contains a Collection of Characteristics. I need to construct a table that looks something like this:
and so on and so on. I'm having a hard time coming up with the jstl logic to handle this. My first attempt went something like this:
Obviously, that didn't work out well. I didn't have the row breaks where I needed them and several characteristic group were on the same row instead of seperate rows. Any tips as to a good solution for this would be much appreciated. Should I not be using a table?
Originally posted by Ben Souther: Hmm I wasn't thinking about lining up the columns. Maybe tables would make more sense.
Is is always the same number of columns?
Yes, it's always the same number of columns. I kind of like the UL LI idea. Been playing around with it. Problem is getting the LI widths to work right. If I text-alright: right, then the bullets don't line up.
The c:forEach tag also allows you to track the status of the loop if you use the "varStatus" attribute (e.g. varStatus="charGroupStatus"). You can then use c:if tags to check whether the index is 0 (i.e. whether it is the first time through the loop) and print out the cells accordingly.
This might not be the most efficient way to do it (because it does the two if checks for every single modelChar), but it seems readable and doesn't involve slightly unsual </tr> <tr> pairs (which the other solution that I thought of would require ;) ) and as long as you don't have thousands upon thousands of modelChars you can probably get away with it