我应该使用dataTable还是panelGrid? JSF [英] Should I use dataTable or panelGrid? JSF
问题描述
<table id="tbl" cellpadding="5" cellspacing="0" border="0" class="display" style="padding-top: 10px;width:100%">
<thead>
<tr>
<th width="20%">Emp No</th>
<th width="15%">title</th>
<th width="20%">Name</th>
<th width="10%">shift</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>
<tbody style="cursor:pointer;">
Yeh aik arzi tehreer hai
</tbody>
</table>
当我开始为我的JSF应用程序转换此代码时,我发现我可以使用< h:dataTable>
或< h:panelGrid>
因为两者都在此作为 html中的表格
。首先我要问的是我应该在这里使用什么?
2怎样才能处理< thead>
,< tfoot>
和< tbody>
因为我没有找到他们的在JSF中备用。所以请任何人都可以付出一些努力来帮助我。谢谢
When I started to convert this code for my JSF app I found that I can use either <h:dataTable>
or <h:panelGrid>
because both are use here as an alternative of table in html
.So first thing which I want to ask is what should I use here?
2ndly how can I handle <thead>
, <tfoot>
and <tbody>
as I didn't find their alternate in JSF.So please can anyone put some effort to help me for this
Thanks
推荐答案
<$ c $如果您(在您的支持bean中)有一组需要显示的对象,则c>< h:dataTable> 是一个不错的选择。例如,如果你有一个对象员工列表(包括Id,Name,Surname等),那么这是最好的选择。
<h:dataTable>
is a good choice if you have (in your backing bean) a set of objects you need to display. For example if you have a List of object Employee (with Id, Name, Surname, etc.) then is the best choice.
在这里你可以找到一个例子< a href =http://www.javabeat.net/2008/04/hdatatable-java-server-faces-jsf/ =nofollow noreferrer>如何使用dataTable 。
Here you can find an example of how to use dataTable.
< h:panelGrid>
是一个不错的选择,如果您以某种方式布局各种元素。一种情况是,当你必须将空间分成两列,分别为80%和20%时。
虽然'我'建议使用(panelGroup)用于此目的,但请参阅 http ://www.w3.org/2002/03/csslayout-howto
<h:panelGrid>
is a good choice if you have layout various elements in an certain way. One case, is when you have to split the space in two columns of 80% and 20% respectively.
Though, 'I' suggest to use (panelGroup) for this purpose see http://www.w3.org/2002/03/csslayout-howto
编辑: 使用< h:dataTable>
对于页眉,页脚等,您必须使用标签< f:facet />
请参阅 JSF中的多个页脚行dataTable
With the <h:dataTable>
For the header, footer, etc. you have to use the tag <f:facet />
see Multiple Footer Rows in a JSF dataTable
这篇关于我应该使用dataTable还是panelGrid? JSF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!