![](/img/trans.png)
[英]<p:commandButton> referencing <p:contentFlow var=“i”> throws javax.el.PropertyNotFoundException: Target Unreachable, identifier 'i' resolved to null
[英]p:commandButton action throws javax.el.PropertyNotFoundException
錯誤是在:
javax.el.PropertyNotFoundException:/index.xhtml:在類型fya.beanpages.IndexBean上找不到屬性'validar'
它看起來像找不到有效的方法。 它認為這是一個屬性。
這是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>
這是托管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;
}
}
}
也許我認為我做錯了事,請您能幫我嗎?
當您沒有正確安裝PrimeFaces時,可能會發生這種情況。 這樣,所有<p:xxx>
標記都被視為模板文本(意味着,Facelets不會將它們解析為JSF組件,而是直接打印為HTML輸出的普通樣式)。 默認情況下,模板文本中的所有EL表達式都被解析為屬性值表達式(例如<p>blah #{bean.foo} blah</p>
),這需要使用getter方法。 所有最初表示方法表達式的EL表達式都將恰好引發此異常,因為在Bean中沒有發現吸氣劑。
要正確安裝PrimeFaces,請確保JAR文件位於webapp的/WEB-INF/lib
(如果您使用的是Eclipse之類的IDE,請確保絕對不要觸摸Build Path設置,如果您曾經在其中粗心地嘗試解決它,全部撤消!),並確保正確重建了項目,並正確清理了服務器的工作文件夾,並且服務器中的部署確實在正確的位置包含PrimeFaces JAR文件。
另外要考慮的是,PrimeFaces 3.0中引入了標簽庫URI http://primefaces.org/ui
。 因此,如果您碰巧擁有PrimeFaces 2.x或更舊的JAR,那么您也可能會遇到這個問題。 您需要將PrimeFaces至少升級到3.0,或者回退到使用2.x兼容的taglib URI http://primefaces.prime.com.tr/ui
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.