How to use li and ul tag in JSF Framework?
+1
A:
You can use standard html mixed with JSF syntax. Just write
<ul>
<li> Apple </li>
<li> Banana </li>
</ul>
I guess what you want is displaying a list from a List
If you are using Facelets, do:
<ul>
<ui:repeat value="#{myBean.items}" var="item">
<li><h:outputText value="#{item.name}"/></li>
</ui:repeat>
</ul>
If you are not, you should. Anyway, you can do the same with the old JSTL and c:forEach
<html ... xmlns:c="http://java.sun.com/jstl/core">
...
<ul>
<c:forEach items="#{myBean.items}" var="item">
<li><h:outputText value="#{item.name}"/></li>
</c:forEach>
</ul>
pakore
2010-07-13 07:38:23
Pakore Inside <li> can i use commandlink?is verbatium needed?
Hari kanna
2010-07-13 07:40:21
inside <li> you can use any JSF tag you want.
pakore
2010-07-13 07:42:09
Pakore We r using Tiles..
Hari kanna
2010-07-13 07:44:09
@Hari kanna see my updated response.
pakore
2010-07-13 07:50:54
@Hari: `f:verbatim` is only needed if you're using the vintage JSF 1.1. Since JSF 1.2 the view handler has been improved to automatically do that. See also [this answer](http://stackoverflow.com/questions/2844843/is-there-any-problem-when-i-mix-jsf-with-plain-html).
BalusC
2010-07-13 11:22:17
A:
You can also use Tomahawk's t:dataList
to render a <ul><li>
in a "jsfish" way without bringing in "plain vanilla" HTML. Useful if you're still on JSF 1.0/1.1 yet and don't want to hassle with f:verbatim
.
<t:dataList layout="unorderedList" value="#{bean.list}" var="item">
<h:outputText value="#{item}" />
</t:dataList>
which generates
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
which look like this
- item 1
- item 2
- item 3
BalusC
2010-07-13 11:27:26