Boa tarde, não estou conseguindo renderizar uma mensagem na tela usando o jsf. Estou tentando fazer um simples login.
package puc.com.visao;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.awt.event.ActionEvent;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
/**
*
* @author welder
*/
@ManagedBean
@RequestScoped
public class Login {
private String nome;
private String senha;
public Login() {
}
/**
* validação do nome e senha sem segurança
*/
public boolean validarLogin(ActionEvent event){
if (ValidaLogin.validar(this.getNome(), this.getSenha())) {
return true;
}else{
return false;
}
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
}
--------------------------------------------------------------------------------
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package puc.com.visao;
/**
*
* @author welder
*/
public class ValidaLogin {
private static String user = "root";
private static String password = "123";
public static boolean validar(String nome, String senha){
if (nome.equalsIgnoreCase(user) && senha.equalsIgnoreCase(password)) {
return true;
}else{
return false;
}
}
}
----------------------------------------------------------------------------------------------------------
JSP
<%--
Document : login
Created on : 03/06/2011, 15:02:02
Author : welder
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>.:: Login do Sistema - Segurança da Informação ::.</title>
</head>
<body>
<f:view>
<h:form>
<h3><h:outputText value="Login do Sistema"/></h3>
</br>
<h5>
<h:outputText value="Usuario:"/><br/>
<h:inputSecret value="#{login.nome}" size="20" maxlength="80"/>
<br/>
<h:outputText value="Senha:"/><br/>
<h:inputSecret value="#{login.senha}" size="20" maxlength="80"/>
<br/>
<h:commandButton actionListener="#{login.validarLogin(event)}" value="logar"/>
<h:outputText value="Nome ou senha inválido!" rendered="#{!login.validarLogin}"/>
</h5>
</h:form>
</f:view>
</body>
</html>
---------------------------------------------------------------------------------------------------------------------------
Stack Trace
An Error Occurred:
/login.jsp(35,21) '#{!login.validarLogin}' Property 'validarLogin' not found on type puc.com.visao.Login
+- Stack Trace
org.apache.jasper.el.JspPropertyNotFoundException: /login.jsp(35,21) '#{!login.validarLogin}' Property 'validarLogin' not found on type puc.com.visao.Login
at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:193)
at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:421)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:853)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1652)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1655)
at com.sun.faces.application.view.JspViewHandlingStrategy.doRenderView(JspViewHandlingStrategy.java:431)
at com.sun.faces.application.view.JspViewHandlingStrategy.renderView(JspViewHandlingStrategy.java:233)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
+- Component Tree
<UIViewRoot id="j_id_jsp_1430188681_0" inView="true" locale="pt_BR" renderKitId="HTML_BASIC" rendered="true" transient="false" viewId="/login.jsp">
<HtmlForm enctype="application/x-www-form-urlencoded" id="j_id_jsp_1430188681_1" inView="true" prependId="true" rendered="true" submitted="false" transient="false">
<HtmlOutputText escape="false" id="j_id2" inView="true" rendered="true" transient="true" value=" <h3>"/>
<HtmlOutputText escape="true" id="j_id_jsp_1430188681_2" inView="true" rendered="true" transient="false" value="Login do Sistema"/>
<HtmlOutputText escape="false" id="j_id3" inView="true" rendered="true" transient="true" value="</h3> </br> <h5> "/>
<HtmlOutputText escape="true" id="j_id_jsp_1430188681_3" inView="true" rendered="true" transient="false" value="Usuario:"/>
<HtmlOutputText escape="false" id="j_id4" inView="true" rendered="true" transient="true" value="<br/> "/>
<HtmlInputSecret disabled="false" id="j_id_jsp_1430188681_4" immediate="false" inView="true" localValueSet="false" maxlength="80" readonly="false" redisplay="false" rendered="true" required="false" size="20" transient="false" valid="true"/>
<HtmlOutputText escape="false" id="j_id5" inView="true" rendered="true" transient="true" value=" <br/> "/>
<HtmlOutputText escape="true" id="j_id_jsp_1430188681_5" inView="true" rendered="true" transient="false" value="Senha:"/>
<HtmlOutputText escape="false" id="j_id6" inView="true" rendered="true" transient="true" value="<br/> "/>
<HtmlInputSecret disabled="false" id="j_id_jsp_1430188681_6" immediate="false" inView="true" localValueSet="false" maxlength="80" readonly="false" redisplay="false" rendered="true" required="false" size="20" transient="false" valid="true"/>
<HtmlOutputText escape="false" id="j_id7" inView="true" rendered="true" transient="true" value=" <br/> "/>
<HtmlCommandButton disabled="false" id="j_id_jsp_1430188681_7" immediate="false" inView="true" readonly="false" rendered="true" transient="false" type="submit" value="logar"/>
<HtmlOutputText escape="true" id="j_id_jsp_1430188681_8" inView="true" transient="false" value="Nome ou senha inválido!"/>
<HtmlOutputText escape="false" id="j_id8" inView="true" rendered="true" transient="true" value=" </h5> "/>
</HtmlForm>
</UIViewRoot>
+- Scoped Variables
Request ParametersName Value
None
View AttributesName Value
None
Request AttributesName Value
login puc.com.visao.Login@1e890b4
Flash AttributesName Value
None
Session AttributesName Value
None
Application AttributesName Value
csfcff com.sun.faces.context.flash.ELFlash@1d8add3
03/06/2011 18:11:18 - Generated by Mojarra/Facelets
OBS.: na linha 119 no método - <h:outputText value="Nome ou senha inválido!" rendered="#{!login.validarLogin}"/>
Alguem pode me ajudar