Should I use dataTable or panelGrid? JSF

﹥>﹥吖頭↗ 提交于 2020-01-05 11:02:24

问题


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

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


回答1:


<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.

Here you can find an example of how to use dataTable.

<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

Edit: 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



来源:https://stackoverflow.com/questions/12104906/should-i-use-datatable-or-panelgrid-jsf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!