简体   繁体   English

p:commandButton操作抛出javax.el.PropertyNotFoundException

[英]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 javax.el.PropertyNotFoundException:/index.xhtml:在类型fya.beanpages.IndexBean上找不到属性'validar'

Its looks like it doesnt find the validar method. 它看起来像找不到有效的方法。 And it thinks it is an attribute. 它认为这是一个属性。

This is the xhtml: 这是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. 这是托管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? 也许我认为我做错了事,请您能帮我吗?

That can happen when you didn't properly install PrimeFaces. 当您没有正确安装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). 这样,所有<p:xxx>标记都被视为模板文本(意味着,Facelets不会将它们解析为JSF组件,而是直接打印为HTML输出的普通样式)。 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. 默认情况下,模板文本中的所有EL表达式都被解析为属性值表达式(例如<p>blah #{bean.foo} blah</p> ),这需要使用getter方法。 All EL expressions which initially represent a method expression would then throw exactly this exception because there's no getter found in the bean. 所有最初表示方法表达式的EL表达式都将恰好引发此异常,因为在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. 要正确安装PrimeFaces,请确保JAR文件位于webapp的/WEB-INF/lib (如果您使用的是Eclipse之类的IDE,请确保绝对不要触摸Build Path设置,如果您曾经在其中粗心地尝试解决它,全部撤消!),并确保正确重建了项目,并正确清理了服务器的工作文件夹,并且服务器中的部署确实在正确的位置包含PrimeFaces JAR文件。

Another thing to take into account, the taglib URI http://primefaces.org/ui was introduced in PrimeFaces 3.0. 另外要考虑的是,PrimeFaces 3.0中引入了标签库URI http://primefaces.org/ui So if you happen to have a JAR of PrimeFaces 2.x or older, then you can also face exactly this problem. 因此,如果您碰巧拥有PrimeFaces 2.x或更旧的JAR,那么您也可能会遇到这个问题。 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 . 您需要将PrimeFaces至少升级到3.0,或者回退到使用2.x兼容的taglib URI http://primefaces.prime.com.tr/ui

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 <p:commandButton> 引用 <p:contentFlow var=“i”> 抛出javax.el.PropertyNotFoundException:目标无法访问,标识符&#39;i&#39;解析为null - <p:commandButton> referencing <p:contentFlow var=“i”> throws javax.el.PropertyNotFoundException: Target Unreachable, identifier 'i' resolved to null <p:graphicImage>在#{bean.foo()。bar()}上抛出javax.el.PropertyNotFoundException,但是#{bean.fooAndBar()}可以工作 - <p:graphicImage> throws javax.el.PropertyNotFoundException on #{bean.foo().bar()}, but #{bean.fooAndBar()} works 带有 CompositeComponent 的 javax.el.PropertyNotFoundException? - javax.el.PropertyNotFoundException with CompositeComponent? ADF:GoButton javax.el.PropertyNotFoundException - ADF : GoButton javax.el.PropertyNotFoundException 支持bean中的javax.el.PropertyNotFoundException - javax.el.PropertyNotFoundException in backing bean 具有Primefaces和dataTable的javax.el.PropertyNotFoundException - javax.el.PropertyNotFoundException with Primefaces and dataTable JSF:ContextAwarePropertyNotFoundException / javax.el.PropertyNotFoundException - JSF: ContextAwarePropertyNotFoundException/javax.el.PropertyNotFoundException 在Spring Boot上运行可运行的JSF应用程序会引发javax.el.PropertyNotFoundException:目标不可访问,标识符解析为null - Running working JSF application as Spring Boot throws javax.el.PropertyNotFoundException: Target Unreachable, identifier resolved to null 尝试解析EL中的布尔属性时出现javax.el.PropertyNotFoundException - javax.el.PropertyNotFoundException when trying to resolve Boolean properties in EL 注释掉的 Facelets 代码仍然调用 EL 表达式,如 #{bean.action()} 并导致 #{bean.action} 上的 javax.el.PropertyNotFoundException - Outcommented Facelets code still invokes EL expressions like #{bean.action()} and causes javax.el.PropertyNotFoundException on #{bean.action}
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM