aspose file tools*
The moose likes Struts and the fly likes logic:iterate question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "logic:iterate question" Watch "logic:iterate question" New topic
Author

logic:iterate question

Chris Stann
Ranch Hand

Joined: Oct 10, 2006
Posts: 49
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
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.


My Blog
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31057
    
232

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.)


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Chris Stann
Ranch Hand

Joined: Oct 10, 2006
Posts: 49
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
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

Good luck,

SCJP 5.0<br />Preparing SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: logic:iterate question