Having this xhtml code:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Simple JSF</title>
</h:head>
<h:body>
<h:form>
<ui:repeat value="#{cart.items}" var="item">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="#{item}" />
</h:panelGrid>
</ui:repeat>
</h:form>
</h:body>
</html>
And the bean:
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean(name = "cart")
@SessionScoped
public class CartBean {
private List<String> items;
public CartBean() {
items = new ArrayList<>();
items.add("shirt");
items.add("skirt");
items.add("trouser");
}
public List<String> getItems() {
return items;
}
}
Shows the three corresponding items in the outputText: "shirt", "skirt" and "trouser" But, changing the body of xhtml like shows:
<h:body>
<h:form>
<p:tabView >
<ui:repeat value="#{cart.items}" var="item">
<p:tab title="#{item}">
<h:panelGrid columns="2" cellpadding="10">
<h:outputText value="#{item}" />
</h:panelGrid>
</p:tab>
</ui:repeat>
</p:tabView>
</h:form>
</h:body>
Showing a tabView whit only one tab (instead of three) and without text in the tab. I dont undernstand why loosing data?