微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何将此HTML表转换为JSF表

我想将这个html表翻译成JSF表
<table border="1">
   <tr>
     <td>OS Verison</td>
     <td>Linux</td>
   </tr>
   <tr>
     <td>Installed packages</td>
     <td>30</td>
   </tr>
   <tr>
     <td>Free HDD Space</td>
     <td>30 GB</td>
   </tr>
   <tr>
     <td>Installed RAM</td>
     <td>2 GB</td>
   </tr>
</table>

我在Google上找到了很多关于如何编写JSF表的例子,该表以数据库的形式从列表中检索数据,但没有一个示例显示如何创建包含两个列的表,如上所述.

P.S

如何重写此代码以实现相同的输出结果?

<h:dataTable id="books"
                             columnClasses="list-column-center,list-column-right,list-column-center,list-column-right" headerClass="list-header"
                             rowClasses="list-row" styleClass="list-
                             background" value="#{DashboardController.getDashboardList()}" var="store">   
                    <h:column>
                          <h:outputText  value="Session Timeout"/>
                          <h:outputText  value="Maximum Logged Users"/>
                    </h:column>
                    <h:column>                       
                          <h:outputText value="#{store.sessionTTL} minutes"/>
                          <h:outputText value="#{store.maxActiveUsers}"/>
                    </h:column>

                    <h:column>
                        <f:facet name="header">
                          <h:outputText  value="one"/>
                        </f:facet>
                    </h:column>
                    <h:column>
                        <f:facet name="header">
                          <h:outputText  value="two"/>
                        </f:facet>
                    </h:column>

                </h:dataTable>

我希望以类似第一个表的基本方式显示数据库表的内容,它有2列,只有一行.

解决方法

<h:panelGrid>是为了.
<h:panelGrid columns="2" border="1">
    <h:panelGroup>OS Verison</h:panelGroup>
    <h:panelGroup>Linux</h:panelGroup>

    <h:panelGroup>Installed packages</h:panelGroup>
    <h:panelGroup>30</h:panelGroup>

    <h:panelGroup>Free HDD Space</h:panelGroup>
    <h:panelGroup>30 GB</h:panelGroup>

    <h:panelGroup>Installed RAM</h:panelGroup>
    <h:panelGroup>2 GB</h:panelGroup>
</h:panelGrid>

请注意,“普通的vanilla HTML”在JSF页面中表现得很好.只有当它仅用于布局和/或演示时,才必须使用JSF组件.

也可以看看:

> Java EE 6 tutorial – Using JSF components

> Laying Out Components with the h:panelGrid and h:panelGroup Tags

> JSF tag documentation

> <h:panelGrid> tag documentation

原文地址:https://www.jb51.cc/html/226505.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐