简体   繁体   English

Primefaces 自动完成错误 completeMethod

[英]Primefaces autocomplete error completeMethod

I have a problem with primefaces autocomplete.我有primefaces自动完成的问题。 The jsf page is as follow : 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" />

when the jsf is called I have this server 500 error:当 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)

My ManagedBean is RechercheRestoMb and it contains he method completeVille我的 ManagedBean 是 RechercheRestoMb,它包含方法 completeVille

If I insert public String completeVille with getters and setters I don't have the error but the autocomplete does not work.如果我使用 getter 和 setter 插入 public String completeVille 我没有错误但自动完成不起作用。

Anyone has an idea for this problem?有人对这个问题有想法吗?

javax.el.ELException: /corpsIndex.xhtml: The class 'fr.afcepf.al25.projetResto.managedBean.RechercheRestoMb' does not have the property 'completeVille'. javax.el.E​​LException: /corpsIndex.xhtml: 类 'fr.afcepf.al25.projetResto.managedBean.RechercheRestoMb' 没有属性 'completeVille'。

This exception means that the EL expression is being interpreted as a property value expression (which requires a getter method), not as a method expression.此异常意味着 EL 表达式被解释为属性值表达式(需要 getter 方法),而不是方法表达式。 Basically, it couldn't find the getCompleteVille() method.基本上,它找不到getCompleteVille()方法。 However, you actually shouldn't need one.然而,你实际上不应该需要一个。 There's more at matter.还有更多问题。

Look closer at the stack trace what happened during rendering:仔细查看渲染过程中发生的堆栈跟踪:

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 is the Facelets representation for EL in template text like so UILeaf > UIInstructions是 EL 在模板文本中的 Facelets 表示,如下所示

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

This is unexpected as you declared the EL expression in a <p:autoComplete> component which should appear as org.primefaces.component.autocomplete.AutoComplete in that line.这是出乎意料的,因为您在<p:autoComplete>组件中声明了 EL 表达式,该组件应该在该行中显示为org.primefaces.component.autocomplete.AutoComplete This thus means that the <p:xxx> tag library is not recognized and is interpreted as template text and thus remain unparsed during generating the HTML output.因此,这意味着<p:xxx>标记库无法识别并被解释为模板文本,因此在生成 HTML 输出期间保持未解析状态。 In effects, you're sending <p:autoComplete> plain vanilla to webbrowser instead of letting JSF generate its HTML output. <p:autoComplete> ,您将<p:autoComplete>普通的 vanilla 发送到 webbrowser,而不是让 JSF 生成其 HTML 输出。

This in turn can have several causes, the most common being:这反过来可能有多种原因,最常见的是:

  • You didn't install PrimeFaces (just drop JAR in /WEB-INF/lib ).您没有安装 PrimeFaces(只需将 JAR 放入/WEB-INF/lib )。
  • You didn't declare its XML namespace (use xmlns:p="http://primefaces.org/ui" ).您没有声明它的 XML 命名空间(使用xmlns:p="http://primefaces.org/ui" )。

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

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