Weblogic jsf2 (iniciante) - does not have the property 'soma'

1 resposta
D

Boa noite galera, to fazendo os execícios de uma apostila com weblogic e jsf2, mas ta lançando uma excecao, vejam se conseguem me ajudar :)

o jsf:

<?xml version="1.0" encoding="ISO-8859-1"?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 

 <html xmlns =" http :// www .w3. org /1999/ xhtml "
 xmlns:h=" http :// java . sun . com / jsf / html ">

 <h:head >
 <title > Calculadora - Soma </title >
 </h:head >

 <h:body >
 <h:form >
 <h:outputLabel value =" Valor A: " />
 <h:inputText value ="#{calculadoraMB.a}" />

 <h:outputLabel value =" Valor B: " />
 <h:inputText value ="#{calculadoraMB.b}" />

 <h:commandButton action ="#{calculadoraMB.soma }" value =" soma " />

 <h:outputLabel value =" Resultado : " />
 <h:outputText value ="#{calculadoraMB.resultado }" />
 </h:form >
 </h:body >
 </html >

o bean:

package br.com.dessu.managedbeans;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import br.com.dessu.sessionbeans.Calculadora;

@ManagedBean
public class CalculadoraMB {
	@EJB
	private Calculadora calculadora;
	private double a;
	private double b;
	private double resultado;
	
	public void soma(){
		this.resultado=this.calculadora.soma(a, b);
	}
	public Calculadora getCalculadora() {
		return calculadora;
	}
	public void setCalculadora(Calculadora calculadora) {
		this.calculadora = calculadora;
	}
	public double getA() {
		return a;
	}
	public void setA(double a) {
		this.a = a;
	}
	public double getB() {
		return b;
	}
	public void setB(double b) {
		this.b = b;
	}
	public double getResultado() {
		return resultado;
	}
	public void setResultado(double resultado) {
		this.resultado = resultado;
	}
}

o erro:

<11/07/2013 23h47min19s BRT> <Error> <javax.enterprise.resource.webcontainer.jsf.application> <BEA-000000> <Error Rendering View[/soma.xhtml]
javax.el.ELException: //C:/workspace/calculadoraWeb/WebContent/soma.xhtml: The class 'br.com.dessu.managedbeans.CalculadoraMB' does not have the property 'soma'.
	at com.sun.faces.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:94)
	at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
	at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
	Truncated. see log file for complete stacktrace
> 
<11/07/2013 23h47min19s BRT> <Error> <HTTP> <BEA-101017> <[ServletContext@1057446[app:calculadoraEAR module:calculadoraWeb path:null spec-version:3.0], request: weblogic.servlet.internal.ServletRequestImpl@3d7a5a[
GET /calculadoraWeb/soma.xhtml HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive

]] Root cause of ServletException.
javax.el.ELException: //C:/workspace/calculadoraWeb/WebContent/soma.xhtml: The class 'br.com.dessu.managedbeans.CalculadoraMB' does not have the property 'soma'.
	at com.sun.faces.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:94)
	at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
	at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
	at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
	Truncated. see log file for complete stacktrace
>

1 Resposta

D

Consegui resolver segue abaixo o arquivo xhtml corrigido:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html  xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
	<f:loadBundle basename="resources.application" var="msg"/>
	<title>Lançador de dado</title>
</h:head>

<h:body>
	<h:form>
		<h:commandButton action ="#{dadoMbFaces.lancaDado}" value =" Lança o Dado " />
		 <h:outputLabel value =" Resultado : " />
		 <h:outputText value ="#{dadoMbFaces. resultado }" />
		 
	</h:form>
</h:body>
</html>
Criado 11 de julho de 2013
Ultima resposta 12 de jul. de 2013
Respostas 1
Participantes 1