Two Laptop Bag
The moose likes Struts and the fly likes JSF: Centering A Table (panelGrid) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "JSF: Centering A Table (panelGrid)" Watch "JSF: Centering A Table (panelGrid)" New topic
Author

JSF: Centering A Table (panelGrid)

Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

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
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

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
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

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
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

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
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

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

Joined: Dec 11, 2003
Posts: 103
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.


Kito D. Mann
Author of JSF in Actionwww.JSFCentral.com - JSF FAQ, news, and info
Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15229

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:
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JSF: Centering A Table (panelGrid)
 
Similar Threads
JSP and XML
Nested Tables and Colspan attribute
Eclipse trouble with HTML error
alignment of image and dat in rows
Multiple forms in a single JSP page