2013-07-31 35 views
0

我需要使用JSF 1.1和Tomahawak显示网格中的项目列表。在JSF 1.1中显示网格中的项目列表

我想这

<h:panelGrid columns="4"> 
    <h:dataTable value="#{globalTVChannelsBean.filteredChannels}" var="channel"> 
     <h:column><h:outputText value="#{channel.channelName}" /></h:column> 
    </h:dataTable> 
</h:panelGrid> 

<h:panelGrid columns="4"> 
    <c:forEach items="#{globalTVChannelsBean.filteredChannels}" var="channel" 
     <h:outputText value="#{channel.channelName}" /> 
    </c:forEach> 
</h:panelGrid> 

但他们都没有工作。你能否看到这个问题,或者提出正确的做法。

+0

你得到什么错误? – fareed

+0

这些值显示在一列中,而我希望它们像网格一样显示在四列中。 – abbas

+0

那是因为你指定了一列! – fareed

回答

0

您需要仔细观察dataTable组件的工作方式。

DataTable为您生成一个HTML表格。在你的情况下,你需要使用ui:repeat,它在数组上循环而不创建HTML表格标签。

<h:panelGrid columns="4"> 
    <ui:repeat value="#{globalTVChannelsBean.filteredChannels}" var="channel"> 
     <h:outputText value="#{channel.channelName}" /> 
    </ui:repeat> 
</h:panelGrid> 
+0

ui:重复项目中没有提供给我。 – abbas

+0

在您的项目中是否可以包含Facelets?如果你不能再尝试使用JSTL c:foreach而不是 – fareed

+0

c:forEach不起作用。 – abbas

0

我不能JSF做到这一点,但是,this帮助与JSTLÇ做它:的forEach。

-1

您需要包括这才能使用c:forEach

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
+0

提到为什么你投下我的答案是有帮助的! –