Jsf datatable

Olá pessoal estou estudando JSF é não estou conseguinto usar listas nas minhas paginas.

PAGINA

<f:view>
<h:dataTable value="#{testeJSF.carros}" var="carros">
<h:outputText value="#{carros.cor}"></h:outputText>
</h:dataTable>
</f:view>

CLASSE

[code]
public class TesteJSF {
private String ola ="ola mundo";
private List<CarroVO> carros;
public TesteJSF() {
// TODO Auto-generated constructor stub
}
public String getOla() {
return ola;
}
public void setOla(String ola) {
this.ola = ola;
}
public List<CarroVO> getCarros(){
carros = new ArrayList<CarroVO>();
CarroVO c = new CarroVO();
c.setCor("azul");
carros.add(c);
CarroVO c1 = new CarroVO();
c.setCor("verde");
carros.add(c1);

	return carros;

}

public void setCarros(List<CarroVO> carros) {
this.carros = carros;
}

}[/code]

public class CarroVO &#123; private String cor; //geteres e settes &#125;

Esta aparecendo a seguinte mensagem:

06/09/2007 13&#58;05&#58;29 org.apache.catalina.core.ApplicationContext log
INFO&#58; WARNING&#58; Component _id0 just got an automatic id, because there was no id assigned yet. If this component was created dynamically &#40;i.e. not by a JSP tag&#41; you should assign it an explicit static id or assign it the id you get from the createUniqueId from the current UIViewRoot component right after creation!
06/09/2007 13&#58;05&#58;29 org.apache.catalina.core.ApplicationContext log
INFO&#58; No Renderer found for component &#123;Component-Path &#58; &#91;Class&#58; javax.faces.component.UIViewRoot,ViewId&#58; /index1.jsp&#93;&#125; &#40;component-family=javax.faces.ViewRoot, renderer-type=javax.faces.Text&#41;
06/09/2007 13&#58;05&#58;29 org.apache.catalina.core.ApplicationContext log
INFO&#58; No Renderer found for component &#123;Component-Path &#58; &#91;Class&#58; javax.faces.component.UIViewRoot,ViewId&#58; /index1.jsp&#93;&#125; &#40;component-family=javax.faces.ViewRoot, renderer-type=javax.faces.Text&#41;
06/09/2007 13&#58;05&#58;29 org.apache.catalina.core.ApplicationContext log
INFO&#58; No Renderer found for component &#123;Component-Path &#58; &#91;Class&#58; javax.faces.component.UIViewRoot,ViewId&#58; /index1.jsp&#93;&#125; &#40;component-family=javax.faces.ViewRoot, renderer-type=javax.faces.Text&#41;
06/09/2007 13&#58;05&#58;29 org.apache.catalina.core.ApplicationContext log
INFO&#58; No Renderer found for component &#123;Component-Path &#58; &#91;Class&#58; javax.faces.component.UIViewRoot,ViewId&#58; /index1.jsp&#93;&#125; &#40;component-family=javax.faces.ViewRoot, renderer-type=javax.faces.Text&#41;
06/09/2007 13&#58;05&#58;29 org.apache.catalina.core.ApplicationContext log
INFO&#58; No Renderer found for component &#123;Component-Path &#58; &#91;Class&#58; javax.faces.component.UIViewRoot,ViewId&#58; /index1.jsp&#93;&#125; &#40;component-family=javax.faces.ViewRoot, renderer-type=javax.faces.Text&#41;

Alguem poderia me ajudar a solucionar isso!

Valeu a ajuda!!

tenta alterar o seu datatable,

&lt;f&#58;view&gt;
&lt;h&#58;dataTable id=&quot;listagem&quot; value=&quot;#&#123;testeJSF.carros&#125;&quot; var=&quot;carros&quot;&gt;
&lt;h&#58;outputText value=&quot;#&#123;carros.cor&#125;&quot;&gt;&lt;/h&#58;outputText&gt;
&lt;/h&#58;dataTable&gt;
&lt;/f&#58;view&gt; 

Isso resolveria o primeiro warning.

Opa,

Está faltado as colunas:

&lt;h&#58;dataTable value=&quot;#&#123;testeJSF.carros&#125;&quot; var=&quot;carros&quot;&gt; &lt;h&#58;column&gt; &lt;f&#58;facet name=&quot;header&quot;&gt;&lt;h&#58;outputText value=&quot;Cor&quot;/&gt;&lt;/f&#58;facet&gt; &lt;h&#58;outputText value=&quot;#&#123;carros.cor&#125;&quot;&gt;&lt;/h&#58;outputText&gt; &lt;/column&gt; &lt;/h&#58;dataTable&gt;

Pessoal o erro ou o não aparecimento da lista ainda persiste, depois das alterações sugeridas!

org.apache.catalina.core.ApplicationContext log
INFO&#58; WARNING&#58; Component _id0 just got an automatic id, because there was no id assigned yet. If this component was created dynamically &#40;i.e. not by a JSP tag&#41; you should assign it an explicit static id or assign it the id you get from the createUniqueId from the current UIViewRoot component right after creation!

Valeu a ajuda!

Erro resolvido!

Obrigado pela ajuda!

A proveitando o topico, existe uma outra maneira de iterar por uma lista sem usar datatable ?
No caso não gostaria de constuir um tabela, queria só os valores soltos!

Valeu a ajuda!

Opa,

ser você estiver usando jsf 1.2, pode usando dentro de um c:forEach.

:okok:

estou usando a 1.1, mas vou trocar para usar o c:forEach

valeu!

Pessoal alterei o codigo para usar o c:forEach, mas não esta funcionando
Se eu fizer algo como

&lt;c&#58;forEach var=&quot;count&quot; begin=&quot;0&quot; end=&quot;5&quot;&gt;
	$&#123;count&#125;
&lt;/c&#58;forEach&gt;

imprime os números normalmente, mas se eu fizer

&lt;c&#58;forEach var=&quot;teste&quot; items=&quot;#&#123;calculatorFromBean.carros&#125;&quot;&gt;	
		$&#123;teste.cor&#125;
&lt;/c&#58;forEach&gt;

ele me diz que

org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE&#58; Servlet.service&#40;&#41; for servlet jsp threw exception
javax.el.PropertyNotFoundException&#58; The class 'java.lang.String' does not have the property 'cor'.
	at javax.el.BeanELResolver.getBeanProperty&#40;BeanELResolver.java&#58;561&#41;
	at javax.el.BeanELResolver.getValue&#40;BeanELResolver.java&#58;261&#41;
	at javax.el.CompositeELResolver.getValue&#40;CompositeELResolver.java&#58;143&#41;
	at org.apache.el.parser.AstValue.getValue&#40;AstValue.java&#58;97&#41;
	at org.apache.el.ValueExpressionImpl.getValue&#40;ValueExpressionImpl.java&#58;186&#41;
	at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate&#40;PageContextImpl.java&#58;923&#41;
	at org.apache.jsp.index2_jsp._jspx_meth_c_005fforEach_005f1&#40;index2_jsp.java&#58;1038&#41;
	at org.apache.jsp.index2_jsp._jspService&#40;index2_jsp.java&#58;125&#41;
	at org.apache.jasper.runtime.HttpJspBase.service&#40;HttpJspBase.java&#58;70&#41;
	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;803&#41;
	at org.apache.jasper.servlet.JspServletWrapper.service&#40;JspServletWrapper.java&#58;393&#41;
	at org.apache.jasper.servlet.JspServlet.serviceJspFile&#40;JspServlet.java&#58;320&#41;
	at org.apache.jasper.servlet.JspServlet.service&#40;JspServlet.java&#58;266&#41;
	at javax.servlet.http.HttpServlet.service&#40;HttpServlet.java&#58;803&#41;
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;290&#41;
	at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;206&#41;
	at org.apache.catalina.core.ApplicationDispatcher.invoke&#40;ApplicationDispatcher.java&#58;654&#41;
	at org.apache.catalina.core.ApplicationDispatcher.processRequest&#40;ApplicationDispatcher.java&#58;445&#41;
	at org.apache.catalina.core.ApplicationDispatcher.doForward&#40;ApplicationDispatcher.java&#58;379&#41;
	at org.apache.catalina.core.ApplicationDispatcher.forward&#40;ApplicationDispatcher.java&#58;292&#41;
	at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch&#40;ServletExternalContextImpl.java&#58;419&#41;
	at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView&#40;JspViewHandlerImpl.java&#58;211&#41;
	at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute&#40;RenderResponseExecutor.java&#58;41&#41;
	at org.apache.myfaces.lifecycle.LifecycleImpl.render&#40;LifecycleImpl.java&#58;132&#41;
	at javax.faces.webapp.FacesServlet.service&#40;FacesServlet.java&#58;140&#41;
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter&#40;ApplicationFilterChain.java&#58;290&#41;
	at org.apache.catalina.core.ApplicationFilterChain.doFilter&#40;ApplicationFilterChain.java&#58;206&#41;
	at org.apache.catalina.core.StandardWrapperValve.invoke&#40;StandardWrapperValve.java&#58;233&#41;
	at org.apache.catalina.core.StandardContextValve.invoke&#40;StandardContextValve.java&#58;175&#41;
	at org.apache.catalina.core.StandardHostValve.invoke&#40;StandardHostValve.java&#58;128&#41;
	at org.apache.catalina.valves.ErrorReportValve.invoke&#40;ErrorReportValve.java&#58;102&#41;
	at org.apache.catalina.core.StandardEngineValve.invoke&#40;StandardEngineValve.java&#58;109&#41;
	at org.apache.catalina.connector.CoyoteAdapter.service&#40;CoyoteAdapter.java&#58;263&#41;
	at org.apache.coyote.http11.Http11Processor.process&#40;Http11Processor.java&#58;844&#41;
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process&#40;Http11Protocol.java&#58;584&#41;
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run&#40;JIoEndpoint.java&#58;447&#41;
	at java.lang.Thread.run&#40;Unknown Source&#41;

A minha pagina esta da seguinte forma:

&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=ISO-8859-1&quot;
    pageEncoding=&quot;ISO-8859-1&quot;%&gt;
&lt;%@taglib uri=&quot;http&#58;//java.sun.com/jsf/html&quot; prefix=&quot;h&quot; %&gt;
&lt;%@taglib uri=&quot;http&#58;//java.sun.com/jsf/core&quot; prefix=&quot;f&quot; %&gt;
&lt;%@taglib uri=&quot;http&#58;//java.sun.com/jstl/core&quot; prefix=&quot;c&quot; %&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http&#58;//www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&gt;
&lt;title&gt;Teste&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;c&#58;forEach var=&quot;teste&quot; items=&quot;#&#123;calculatorFromBean.carros&#125;&quot;&gt;	
		$&#123;teste.cor&#125;
&lt;/c&#58;forEach&gt;

&lt;/body&gt;
&lt;/html&gt;

Alguem sabe o pq do erro?

valeu a ajuda!!!

Bom,

Cada item tem certeza que calculatorFromBean.carros retorna uma lista de carros que tem a propriedade getCor? Pelo erro está retornando uma lista/array de strings.

:okok: