【问题标题】:How to translate this HTML table into JSF table如何将此 HTML 表转换为 JSF 表
【发布时间】:2012-03-09 18:27:30
【问题描述】:

我想把这个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 表,这些表从数据库中检索数据作为列表,但没有一个示例显示如何创建具有上述两列的表。

附言

我如何重写这段代码以获得相同的输出结果?

                    <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 列,只有一行。

【问题讨论】:

    标签: java jsf


    【解决方案1】:

    &lt;h:panelGrid&gt; 是为了。

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

    请注意,“plain vanilla HTML”在 JSF 页面中同样有效。仅当 JSF 组件仅用于布局和/或演示时,您必须使用它是不正确的。

    另见:

    【讨论】:

    • 我可以用 做同样的结果吗?
    • 不,它不适合。它适用于基于List&lt;Entity&gt; 的动态表。你有一个静态表。再次查看 Java EE 6 教程。
    • 我想强调 "请注意,"plain vanilla HTML" 在 JSF 页面中同样有效。您必须使用 JSF 组件仅用于布局和/或演示,这不是真的。”
    猜你喜欢
    • 2013-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    相关资源
    最近更新 更多