2015-11-05 93 views
-1

我有一個primefaces自動完成的問題。 JSF頁面是如下:Primefaces自動完成錯誤completeMethod

<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

如果我插入公共字符串completeVille與getter和setters我沒有錯誤,但自動完成不起作用。

任何人都有這個問題的想法?

+0

您可以發佈您的類'rechercheRestoMb'和方法'completeVille' –

+0

多問一個[MCVE](參見:http://www.stackoverflow.com/tags/jsf/info] – Kukeltje

+0

在你的帖子你談了很多關於這個bean的信息,但是你不會發布它......爲什麼?只要看看PrimeFaces的展示,並將他們的例子與你的代碼進行比較。 – Kukeltje

回答

1

javax.el.ELException: /corpsIndex.xhtml: The class 'fr.afcepf.al25.projetResto.managedBean.RechercheRestoMb' does not have the property 'completeVille'.

此異常意味着EL表達被解釋爲一個屬性值表達式(要求的吸氣劑的方法),而不是作爲一種方法表達。基本上,它找不到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> 

這是出乎意料的,因爲你聲明的EL表達式在<p:autoComplete>組件中應該顯示爲org.primefaces.component.autocomplete.AutoComplete。這意味着<p:xxx>標記庫不被識別並被解釋爲模板文本,因此在生成HTML輸出期間保持未解析。在效果中,您將<p:autoComplete>普通香草發送到網頁瀏覽器,而不是讓JSF生成其HTML輸出。

反過來,這可能有幾個原因,最常見的是:

  • 您沒有安裝PrimeFaces(剛落,在/WEB-INF/lib JAR)。
  • 您沒有聲明其XML名稱空間(使用xmlns:p="http://primefaces.org/ui")。