Thursday, August 13, 2009

How to Center an ADF Faces Table

I wanted to edit a web application page to center an ADF Table (<af:table> component). The table was very small, with only two columns, and I didn't need to modify any of the others in my application. The Table component has no attribute controlling how to align it when it is narrower than the displayed page. I could accomplish my goal by creating a custom skin, but that would just be overkill. The solution was so simple I almost didn't think of it.

Here are the steps:
  • Create your Table as you normally would.
  • Move the Table inside a PanelHorizontal (<af:panelhorizontal>) component.
  • Set the Halign attribute of the PanelHorizontal component to center.
Done! I wish everything were that easy.