Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF: Centering A Table (panelGrid)

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There doesn't seem to be any way change the alignment of a Table using the h anelGrid component. I would like to center a table on the screen at 50% width. Using a regular table:



Anyone know how to go about this?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, here is what I had to do. I created a gridPanel with a width of 100% of my screen and 1 column. Then I added another gridPanel inside that one so it would be a new table in the TD. On the first gridPanel I had to apply a rowClasses property with a style that aligns it's TD in the center.

Long story short:



And the center-td style simply has text-align: center;.
[ September 01, 2004: Message edited by: Gregg Bolinger ]
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CRAP!! text-align: center; is IE only. Or it just doesn't work in Firefox. Anyone know a w3c standard way to do this?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the reading I have been doing it would appear that there isn't a standard way to center a table using CSS. So now my question would be why doesn't the HtmlPanelGrid component have an "align" property?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Work around as of right now is to:



Still would have been better to have an align property in the component though.
 
Kito Mann
author
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gregg Bolinger:
Work around as of right now is to:



Still would have been better to have an align property in the component though.



Gregg,

So, the align attribute has been deprecated in HTML 4.01, so it wasn't included in JSF. The suggestion is to use CSS, which is tricky, but possible. See this document.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, the align attribute has been deprecated in HTML 4.01, so it wasn't included in JSF. The suggestion is to use CSS, which is tricky, but possible. See this document.

Well, that kind of stinks. Even the standard isn't standard. :roll:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic