2

如何在 JSF 中获得以下结果

<div id="tagcloud">
    <a href="#" rel="0.1">Lorem</a>
    <a href="#" rel="2">ipsum</a>
    <a href="#" rel="3">dolor</a>
    <a href="#" rel="4">sit</a>
    <a href="#" rel="5">amet,</a>
    <a href="#" rel="6">consectetur</a>
    <a href="#" rel="7">adipisicing</a>
</div>

我试过了<t:datatable><t:datalist>但两者都做不到。

4

2 回答 2

4

Assuming you use Facelets, the following should do it:

<div id="tagcloud">
    <t:dataList value="#{backingBean.items}" var="item" layout="simple">
        <a href="#" rel="#{item.rel}">#{item.name}</a>
    </t:dataList>
</div>

If you're using JSP (hope not), you can replace #{item.name} with an h:outputText.

backingBean.items in the example points to some backing bean that returns a List with the values that differ for each row.

于 2011-12-10T15:56:37.257 回答
4

为什么不使用jstl

<c:forEach var="person" items="${people.people}">
        <tr>
          <td>${person.name}</td>
          <td>${person.age}</td>
          <td>${person.height}</td>
        </tr>
      </c:forEach>

或者

<ui:repeat value="#{TableBean.perInfoAll}" var="info">
   <li> 
  <h:inputText value="#{info.id}" />
  <h:inputText value="#{info.name}" />
   </li> 
  </ui:repeat>
于 2011-12-11T16:07:09.977 回答