aspose file tools*
The moose likes Struts and the fly likes JSF: Centering A Table (panelGrid) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSF: Centering A Table (panelGrid)" Watch "JSF: Centering A Table (panelGrid)" New topic
Author

JSF: Centering A Table (panelGrid)

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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?


GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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

Joined: Jul 11, 2001
Posts: 15299
    
    6

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

Joined: Jul 11, 2001
Posts: 15299
    
    6

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

Joined: Jul 11, 2001
Posts: 15299
    
    6

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: 116
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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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://aspose.com/file-tools
 
subject: JSF: Centering A Table (panelGrid)