Skip to main content

can't make ui:repeat work

3 replies [Last post]
kaghamdi
Offline
Joined: 2004-04-06
Points: 0

Hello

I have a web app with ui:repeat and h:dataTable tags. the repeat tag does not work while dataTable works. what did I do wrong in here. see code below

My index.xhtml has the following contens:

= Start ============================

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">

<h1>Repeat Tag</h1>
<ul>
<ui:repeat var="color1" value="#{colorsBean.colors}">
<li>#{color1}</li>
</ui:repeat>
</ul>

<hr/>

<h1>DataTable Tag</h1>
<ul>
<h:dataTable var="color2" value="#{colorsBean.colors}">
<h:column>
<f:facet name="header">
<h:outputText value="Color" />
</f:facet>
<h:outputText value="#{color2}"/>
</h:column>
</h:dataTable>
</ul>
</html>

-->
= End ============================

ColorsBean is as follows:

== Start ===========================
public class ColorsBean {
String []colors = new String[] {"White","Black","Freen","Blue","Red","Yellow","Cyan"};

public String[] getColors() {
return colors;
}

public void setColors(String[] colors) {
this.colors = colors;
}
}

= End ============================

the libraries I have under WEB-INF/lib are:
- jsf-api.jar
- jsf-facelets-1.1.11.jar
- jsf-impl.jar

==============================

here is the page output:

Repeat Tag
--------------------------------------------------------------------------------
DataTable Tag

Color
White
Black
Freen
Blue
Red
Yellow
Cyan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
frank_langelage
Offline
Joined: 2006-07-12
Points: 0

Is the header really correctly displayed here or tis there a copy/paste error?
There should not ba a
within the -Tag and the DOCTYPE.

Adding a to this page might give you a clue what's wrong / missing.

kaghamdi
Offline
Joined: 2004-04-06
Points: 0

the header is correctly displayed as I have it in the index.xhtml page.

I added at the end of the page but I've got no messages.

frank_langelage
Offline
Joined: 2006-07-12
Points: 0

My guess is, that the line beak symbols (br) are causing the trouble.
The br in front of the ui namespace declaration might cause the rest of the line is ignored.
If I copy your code into my eclipse everything is red (error) and yellow (warning).
Remove the br-tags in the header and add the missing body tag h:body-tag.