Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
765 views
in Technique[技术] by (71.8m points)

jsf - p:commandButton action throws javax.el.PropertyNotFoundException

The error is in:

javax.el.PropertyNotFoundException: /index.xhtml: Property 'validar' not found on type fya.beanpages.IndexBean

Its looks like it doesnt find the validar method. And it thinks it is an attribute.

This is the xhtml:

<!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:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui">

<h:head>  
  <title>FYA WEB</title>
</h:head>  

<h:body>  
    <ui:composition template="/base/base.xhtml">
    <ui:param name="title" value="FYA Web Login"/>
        <ui:define name="content">
            <h:form id="form">  
                <p:panel id="panel" header="Inicio Sesión">  
                    <p:messages id="panelmsg"/>  

                    <h:panelGrid columns="3">  
                        <h:outputLabel for="nomUsuario" value="Usuario: *" />  
                        <p:inputText id="nomUsuario" value="#{login.usu.nomusuario}" required="true" label="Usuario"/>

                        <h:outputLabel for="pwdUsuario" value="Contrase?a: *" />  
                        <p:password id="pwdUsuario" value="#{login.usu.contrase?a}" label="Contrase?a" required="true"/>  
                    </h:panelGrid>  

                    <p:commandButton id="btnIniciar" value="Iniciar Sesión" action="#{login.validar}" update="panelmsg" ajax="true"/>  
                </p:panel>  
            </h:form>
        </ui:define>
    </ui:composition>        
</h:body>

This is the managed Bean.

package pe.edu.cibertec.managed;
@ManagedBean(name="login")
public class LoginBean {

private Usuario usuario=new Usuario();
private static LoginService loginService= new LoginServiceImpl();

public Usuario getUsuario() {
    return usuario;
}

public void setUsuario(Usuario usuario) {
    this.usuario = usuario;
}

public String validar() throws Exception {
    if(loginService.validar(usuario))
        return "paginas/principal";
    else{
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Datos Incorrectos"));
        return null;
    }
}


}

Maybe i think im doing something wrong, can you help me please?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

That can happen when you didn't properly install PrimeFaces. This way all <p:xxx> tags are treated as template text (meaning, they are not parsed as JSF components by Facelets but printed plain vanilla straight to HTML output). All EL expressions in template text are by default resolved as property value expressions (like as in <p>blah #{bean.foo} blah</p>) which requires a getter method. All EL expressions which initially represent a method expression would then throw exactly this exception because there's no getter found in the bean.

To properly install PrimeFaces, make sure that the JAR file is in webapp's /WEB-INF/lib (if you're using any IDE like Eclipse, make sure that you absolutely do not touch Build Path setting, if you ever fiddled there in a careless attempt to solve it, undo it all!), and make sure that the project is properly rebuilt and that the server's work folder is properly cleant up and that the deploy in the server does contain the PrimeFaces JAR file in the right place.

Another thing to take into account, the taglib URI http://primefaces.org/ui was introduced in PrimeFaces 3.0. So if you happen to have a JAR of PrimeFaces 2.x or older, then you can also face exactly this problem. You'd need to either upgrade PrimeFaces to at least 3.0, or to fall back to using 2.x compatible taglib URI http://primefaces.prime.com.tr/ui.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...