I'm using logic:iterate to build rows and cells of a table.
The outer iterator creates my rows and the inner creates my cells.
The trouble is that I want cells in the first column to be aligned to left and the rest aligned to right. How can I do this?
[ October 31, 2008: Message edited by: Chris Stann ] [ October 31, 2008: Message edited by: Chris Stann ]
EXCEL IN ALL YOU DO
Vinod K Singh
Ranch Hand
Joined: Sep 30, 2008
Posts: 198
posted
Create a local variable and reset that to 0 before entering in inner loop and keep on incrementing it there. That way you will know when first column is being written and align that accordingly.
Chris, Better still would be store the values in a form that represents what they are. If you have a specific object, it would be better to have the fields named (ex-Book has a title, author, ISBN, etc) and reference those without going through a loop.
If you have some generic query and the first column is a title/label, you could have a Row object with a String title/label and Collection for the rest.
There must be something special about that first column for it to be displayed differently. And it's better for you model to know about it than force the view to handle it. (Java code in a JSP is an anti-pattern which should get you to think about whether things are designed in the best possible way.)
"The set strikes me as something like the set of potatoes, radishes, farming, and lunch. " - a colleague's way of comparing both overlapping and disparate groups. made me laugh and thought of the ranch
Chris Stann
Ranch Hand
Joined: Oct 10, 2006
Posts: 47
posted
It has been a while since the original post but I wanted to update with my solution, for posterity.
I ended up using indexId which is used to index the columns within a table. If you look below, the solution is rather elegant, if I say so myself. :-)
Alejandro Galvan
Ranch Hand
Joined: Jan 02, 2008
Posts: 48
posted
Hi,
Have you tried Displaytag? it gives you a table from a list previosly setted in the request scope, it can show all the attributes, or just what you defined, in columns, check it at: its site