I am a beginner in Java EE and I am using an Algaworks e-book "Java EE 7, with JSF, PrimeFaces and CDI. Even ManagedBean
occurred normally, but when I started with the backing bean Java could not find the property with HtmlInputText
As the eBook example I changed the class NomeBean
as follows:
NamesBean.java
@ManagedBean
@ViewScoped
public class NomesBean {
private String nome;
private List<String> nomes = new ArrayList<>();
private HtmlInputText inputNome;
private HtmlCommandButton botaoAdicionar;
public void adicionar() {
this.nomes.add(nome);
// desativa campo e botão quando mais que 3 nomes
// forem adicionados
if (this.nomes.size() > 3) {
this.inputNome.setDisabled(true);
this.botaoAdicionar.setDisabled(true);
this.botaoAdicionar.setValue("Muitos nomes adicionados...");
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public List<String> getNomes() {
return nomes;
}
}
names.xhtml
<!DOCTYPE html>
<html xmlns="http://www.w3.org/199/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Lista Nomes</title>
</h:head>
<h:body>
<h:form>
Nome: <h:inputText value="#{nomesBean.nome}" binding="#{nomesBean.inputNome}" />
<br/>
<h:commandButton value="Adicionar" action="#{nomesBean.adicionar}" binding="#{nomesBean.botaoAdicionar}" />
<ol>
<ui:repeat var="nome" value="#{nomesBean.nomes}">
<li>#{nome}</li>
</ui:repeat>
</ol>
</h:form>
</h:body>
</html>
Error output:
HTTP Status 500 - /nomes.xhtml @10,85 binding="#{nomesBean.inputNome}": Property 'inputNome' not found on type com.algaworks.financeiro.model.NomesBean
type Exception report
message /nomes.xhtml @10,85 binding="#{nomesBean.inputNome}": Property 'inputNome' not found on type com.algaworks.financeiro.model.NomesBean
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: /nomes.xhtml @10,85 binding="#{nomesBean.inputNome}": Property 'inputNome' not found on type com.algaworks.financeiro.model.NomesBean
javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
javax.el.PropertyNotFoundException: /nomes.xhtml @10,85 binding="#{nomesBean.inputNome}": Property 'inputNome' not found on type com.algaworks.financeiro.model.NomesBean
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1943)
com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:1149)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.createComponent(ComponentTagHandlerDelegateImpl.java:596)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:175)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:202)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:202)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:161)
com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:991)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
javax.el.PropertyNotFoundException: Property 'inputNome' not found on type com.algaworks.financeiro.model.NomesBean
javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:268)
javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:221)
javax.el.BeanELResolver.property(BeanELResolver.java:355)
javax.el.BeanELResolver.getValue(BeanELResolver.java:95)
com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
org.apache.el.parser.AstValue.getValue(AstValue.java:167)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(ApplicationImpl.java:1943)
com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:1149)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.createComponent(ComponentTagHandlerDelegateImpl.java:596)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:175)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:202)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:137)
com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:202)
javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:120)
javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:95)
com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:87)
com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:161)
com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:991)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
note The full stack trace of the root cause is available in the Apache Tomcat/8.0.20 logs.
Apache Tomcat/8.0.20
But for more than three hours with Google search I could not solve the problem.