File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes dataTable in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "dataTable in JSF" Watch "dataTable in JSF" New topic

dataTable in JSF

Dwijen Bhattacharjee

Joined: Mar 31, 2008
Posts: 26
Hi all,
I am new to JSF .In my application I am using <h:dataTable> to populate a dynamic table .I have two columns "NUMBER" and "NAME".I am using the following Code ---
<h:dataTable id="dt1" value="#synergyCustomerManagementBeanHandle.result}" var="item" border="1" cellpadding="0" cellspacing="0" width="100%" bgcolor="white" >
<h:column >
<f:facet name="header" >
<hutputText value="Number" />
<hutputText value="#{item.number}"></hutputText>
<f:facet name="header">
<hutputText value="Name" />
<hutputText value="#{}"></hutputText>

NOw The problem is both the column taking the same space .but i want that the size of the two column will be 20%(NUMBER) and 80%(NAME). but how to do that because
<h:column>,<f:facet> nothing cotains property like width .

How can I do this kind of alignment?
Thanks in Advance.
Alexander Bell

Joined: Mar 31, 2008
Posts: 7

you can use the "columnClasses" attribute of the h:dataTable Tag.
You can specify for every column one style-class.


You can specify styles for the rows as well with the "rowClasses"-Attribute

See more Examples with JSF-Datatables on


Visit <a href="" target="_blank" rel="nofollow"></a>
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

"Alexander Bell",
Please check your private messages regarding an important administrative matter.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1850

DataTable in JSF

Krishna Srinivasan
OCAJP 7/8 Exam, 400+ OCPJP Mock Questions
I agree. Here's the link:
subject: dataTable in JSF
It's not a secret anymore!