E ae galera, to com o seguinte problema, já passei um tempão tentando resolver e nada, então se alguem puder dar uma ajuda agradeço mesmo…
Implementei uma tela de login, e a principio quando submeto os dados a primeira vez, tudo funciona da forma correta, tipo informo usuário e senha incorretos
o metodo no bean é executado e retorna para a mesma página informando o ocorrido. Porém, depois de voltar para a página se eu tentar informar o usuario e a senha novamente e submeter, acontece o seguinte erro…
javax.el.PropertyNotFoundException: /pages/login.xhtml @34,219 value="#{loginBean.user.nickName}": Target Unreachable, ‘user’ returned null
estou usando JSF versão 1.2, facelets
Meu bean esta desta forma
//Construtor
public LoginBean(){
this.user = new User();
this.message = null;
}
//Método
public String validateInput(){
this.setUser(loadProfile(this.getUser().getNickName(), this.getUser().getPassword()));
if(this.getUser()==null){
this.setMessage("Usuário ou senha inválidos!!!");
return null;
}else if(this.getUser().getId() > 0){
//Carregar na memória recursos do usuário. -1 indica que são todos os recursos
this.getUser().setUserResource(LoginPersistence.getInstance().getUserPrivilegies(this.getUser()));
setUserSession(this.getUser());
return "loginOk";
}
return null;
}
e meu xhtml desta forma
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<head>
<a4j:loadStyle src="../css/generic.css"></a4j:loadStyle>
<a4j:loadStyle src="../css/login.css"></a4j:loadStyle>
</head>
<f:view>
<t:saveState value="#{loginBean.user}"></t:saveState>
<body>
<ui:composition template="../templates/logintemplate.xhtml">
<ui:define name="header">
Agrolog
</ui:define>
<ui:define name="content_login">
<script src="../scripts/login.js" type="text/javascript" ></script>
<h:form id="login" prependId="false">
<t:panelGrid columns="1" style="text-align: center;">
<rich:panel style=" width : 295px;" headerClass="header_login" bodyClass="corpo_login">
<f:facet name="header">
Login
</f:facet>
<t:panelGrid columns="1">
<t:panelGrid columns="2">
<t:panelGrid columns="2">
<h:outputText value="Usuário:" styleClass="label_login"/>
<h:inputText id="usr" value="#{loginBean.user.nickName}" required="true" maxlength="20" requiredMessage="Campo Obrigatório" styleClass="campo_obrigatorio_150" onkeypress="enterValor(event.keyCode)"/>
<t:panelGroup colspan="2"><rich:message for="usr"/></t:panelGroup>
<h:outputText value="Senha:" styleClass="label_login"/>
<h:inputText id="pswd" value="#{loginBean.user.password}" required="true" maxlength="20" requiredMessage="Campo Obrigatório" styleClass="campo_obrigatorio_150" onkeypress="enterValor(event.keyCode)"/>
<t:panelGroup colspan="2"><rich:message for="pswd"/></t:panelGroup>
</t:panelGrid>
<h:commandLink id="login_command" action="#{loginBean.validateInput}" type="submit">
<img src="#{facesContext.externalContext.requestContextPath}/images/cadeado.png" border="0" align="right" />
</h:commandLink>
<t:panelGroup colspan="2" style="text-align: right;">
<h:commandLink action="#{loginBean.validateInput}" type="submit" value="Problemas com a senha?" styleClass="mensagem_senha"/>
</t:panelGroup>
</t:panelGrid>
</t:panelGrid>
</rich:panel>
<t:outputLabel value="#{loginBean.message}" styleClass="erro_campo"></t:outputLabel>
</t:panelGrid>
<script>foco();</script>
</h:form>
</ui:define>
<ui:define name="footer">
Direitos reservados
</ui:define>
</ui:composition>
</body>
</f:view>
</html>
Fico no aguardo de alguma ajuda
Obrigado