• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

logic:iterate question

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author & internet detective
Posts: 41125
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.)
 
Chris Stann
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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. :-)

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic