繁体   English   中英

Primefaces 自动完成错误 completeMethod

[英]Primefaces autocomplete error completeMethod

我有primefaces自动完成的问题。 jsf 页面如下:

<h:inputText class="form-control" style="" for="villeRecherche"/>
<p:autoComplete id="villeRecherche"
value="#{rechercheRestoMb.selectedVille}"
completeMethod="#{rechercheRestoMb.completeVille}"
converter="convertisseurVille" var="c" itemLabel="#{c.ville}"
itemValue="#{c}" forceSelection="true" required="true" />

当 jsf 被调用时,我有这个服务器 500 错误:

javax.el.ELException: /corpsIndex.xhtml: The class 'fr.afcepf.al25.projetResto.managedBean.RechercheRestoMb' does not have the property 'completeVille'.
    com.sun.faces.facelets.compiler.AttributeInstruction.write(AttributeInstruction.java:94)
    com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
    com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
    javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
    com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)

我的 ManagedBean 是 RechercheRestoMb,它包含方法 completeVille

如果我使用 getter 和 setter 插入 public String completeVille 我没有错误但自动完成不起作用。

有人对这个问题有想法吗?

javax.el.E​​LException: /corpsIndex.xhtml: 类 'fr.afcepf.al25.projetResto.managedBean.RechercheRestoMb' 没有属性 'completeVille'。

此异常意味着 EL 表达式被解释为属性值表达式(需要 getter 方法),而不是方法表达式。 基本上,它找不到getCompleteVille()方法。 然而,你实际上不应该需要一个。 还有更多问题。

仔细查看渲染过程中发生的堆栈跟踪:

com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183)
javax.faces.render.Renderer.encodeChildren(Renderer.java:168)

UILeaf > UIInstructions是 EL 在模板文本中的 Facelets 表示,如下所示

<p>Welcome, #{user.name}</p>

这是出乎意料的,因为您在<p:autoComplete>组件中声明了 EL 表达式,该组件应该在该行中显示为org.primefaces.component.autocomplete.AutoComplete 因此,这意味着<p:xxx>标记库无法识别并被解释为模板文本,因此在生成 HTML 输出期间保持未解析状态。 <p:autoComplete> ,您将<p:autoComplete>普通的 vanilla 发送到 webbrowser,而不是让 JSF 生成其 HTML 输出。

这反过来可能有多种原因,最常见的是:

  • 您没有安装 PrimeFaces(只需将 JAR 放入/WEB-INF/lib )。
  • 您没有声明它的 XML 命名空间(使用xmlns:p="http://primefaces.org/ui" )。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM