The controller don't call a method in managed bean!
[nobr]Hello.
I have a managed bean (ProdutoManagedBean) thats have a doRecuperarTodos method. When in a .jsp (CadastrarProduto.jsp) I try to call that method, this exception occurs:
javax.servlet.ServletException: Theclass'br.com.exemplo.apresentacao.ProdutoManagedBean' does not have the property'doRecuperarTodos'.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:231)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
root cause
javax.el.PropertyNotFoundException: Theclass'br.com.exemplo.apresentacao.ProdutoManagedBean' does not have the property'doRecuperarTodos'.
javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:561)
javax.el.BeanELResolver.getValue(BeanELResolver.java:261)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:62)
com.sun.el.parser.AstValue.getValue(AstValue.java:117)
com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
javax.faces.component.UIData.getValue(UIData.java:577)
javax.faces.component.UIData.getDataModel(UIData.java:1056)
javax.faces.component.UIData.setRowIndex(UIData.java:417)
com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:85)
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:809)
javax.faces.component.UIData.encodeBegin(UIData.java:873)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:881)
javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:827)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:883)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:889)
com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:271)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:182)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:133)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:244)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:231)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
***************************************************************************
This is the code forProdutoManagedBean.java:
/*
* ProdutoManagedBean.java
*
* Created on 16 de Outubro de 2006, 17:37
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package br.com.exemplo.apresentacao;
import br.com.exemplo.negocio.entidade.Produto;
import br.com.exemplo.negocio.regra.ProdutoRemote;
import java.util.List;
import javax.ejb.EJB;
publicclass ProdutoManagedBeanimplements java.io.Serializable{
privateProdutoproduto;
private @EJB ProdutoRemote produtoRemote;
public ProdutoManagedBean(){
this.produto =new Produto();
}
public Integer getId(){
return this.produto.getId();
}
publicvoid setId(Integer $id){
this.produto.setId($id);
}
public String getNome(){
return this.produto.getNome();
}
publicvoid setNome(String $nome){
this.produto.setNome($nome);
}
public Double getPreco(){
return this.produto.getPreco();
}
publicvoid setPreco(Double $preco){
this.produto.setPreco($preco);
}
public String doInserir(){
this.produtoRemote.inserir(this.produto);
return"sucesso";
}
publicvoid doAlterar(){
this.produtoRemote.alterar(this.produto);
}
publicvoid doRemover(){
this.produtoRemote.remover(this.produto);
}
public List<Produto> doRecuperarTodos(){
return this.produtoRemote.recuperarTodos();
}
}
***************************************************************************
This is the code forCadastroDeProduto.jsp:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>:: Controle de Pedidos :: Cadastro de Produto</title>
</head>
<body>
<f:view>
<h1>Cadastro De Produto</h1>
<h:form>
<br><br>
<h:panelGrid columns="2">
<h:outputText value="Nome:"/>
<h:inputText id="nome" value="#{ProdutoManagedBean.nome}" title="Digite o nome aqui..."/>
<h:outputText value="Pre鏾:"/>
<h:inputText id="preco" value="#{ProdutoManagedBean.preco}" title="Digite o pre鏾 aqui..."/>
<h:commandButton id="btnDoInserir" action="#{ProdutoManagedBean.doInserir}" value="Inserir"/>
<h:commandButton id="btnDoAlterar" action="#{ProdutoManagedBean.doAlterar}" value="Alterar"/>
</h:panelGrid>
<br><br>
<h2><h:outputText value="Produtos J?Cadastrados"/></h2>
<h:dataTable value="#{ProdutoManagedBean.doRecuperarTodos}" var="produto">
<h:column>
<f:facet name="header">
<h:outputText value="C骴igo"/>
</f:facet>
<h:outputText value="#{produto.id}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Nome"/>
</f:facet>
<h:outputText value="#{produto.nome}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Pre鏾"/>
</f:facet>
<h:outputText value="#{produto.preco}"/>
</h:column>
</h:dataTable>
</h:form>
</f:view>
</body>
</html>
***************************************************************************
This is the code forfaces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- =========== FULL CONFIGURATION FILE ================================== -->
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
<managed-bean>
<managed-bean-name>ProdutoManagedBean</managed-bean-name>
<managed-bean-class>br.com.exemplo.apresentacao.ProdutoManagedBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/paginas/produto/CadastroDeProduto.jsp</from-view-id>
<navigation-case>
<from-action>#{ProdutoManagedBean.doInserir}</from-action>
<from-outcome>sucesso</from-outcome>
<to-view-id>/paginas/Sucesso.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>falha</from-outcome>
<to-view-id>/paginas/Falha.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
When I comment the dataTable code in the JSP, the page is renderized, but when I click in the Inserir button, the method doInserir ins't called to!
In this managed bean, only de get's are called (thanks netbeans debbuger! :). So i try to rename de doInserir to getDoInserir, but it ins't called. :(
Someone can help-me?
Thanks in advance.[/nobr]

