2012-12-06 29 views
-2

加入F:AJAX標籤到我的JSF頁面,使用AJAX使用F:阿賈克斯獲得javax.el.PropertyNotFoundExceptionTarget不可達,標識符 'testBean就' 解析爲空

<td class="row-center" bgcolor="#FFFFFF" > 
<h:commandButton value="run test" action="#{TestBean.runTest1}"> 
    <f:ajax render="output" /> 
</h:commandButton> 
</td> 

我豆的希望:

@ManagedBean 
@RequestScoped 
public class TestBean implements Serializable { 

public void runTest1() throws InvalidFormatException, IOException, InterruptedException { 


} 

一直在努力前加入F:AJAX標籤

任何想法,我做錯了,如何解決?

以下錯誤信息:

中出現錯誤:

javax.el.PropertyNotFoundException: /index.xhtml @102,119 action="#{TestBean.runTest1}": Target Unreachable, identifier 'TestBean' resolved to null 
+- Stack Trace 
javax.faces.el.EvaluationException: javax.el.PropertyNotFoundException: /index.xhtml @102,119 action="#{TestBean.runTest1}": Target Unreachable, identifier 'TestBean' resolved to null 
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:95) 
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:101) 
    at javax.faces.component.UICommand.broadcast(UICommand.java:315) 
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:791) 
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1256) 
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) 
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:181) 
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:641) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879) 
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:600) 
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1703) 
    at java.lang.Thread.run(Thread.java:722) 
Caused by: javax.el.PropertyNotFoundException: /index.xhtml @102,119 action="#{TestBean.runTest1}": Target Unreachable, identifier 'TestBean' resolved to null 
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:107) 
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) 
    ... 20 more 
+0

ManagedBean的默認名稱以小寫字母開頭,嘗試'#{testBean.runTest1}' – elias

+0

賓果遊戲!將#{TestBean.runTest1}更改爲#{testBean.runTest1},現在它似乎在查找Bean,但現在得到新錯誤:/index.xhtml @ 106,119 value =「#{testBean.runTest1Result}」:Property'runTest1Result'找不到類型com.vigilance.jsf.TestBean 將在上面進行編輯以反映新問題 – user840930

+1

這個「打字錯誤」問題不可能是因爲您最初在問題中隱含的「」而引起的。在將其轉化爲問題之前,您應該更仔細地對其進行測試。即當你刪除''時,問題真的會消失嗎?正如你所暗示的那樣? – BalusC

回答

1

通過使私有財產和刪除參數的getter靜態修飾符和setter解決找不到屬性錯誤:

private static String runTest1Result; 

public String getRunTest1Result() { 
    return runTest1Result; 
} 

public void setRunTest1Result(String runTest1Result) { 
    TestBean.runTest1Result = runTest1Result; 
} 

初始javax.el.PropertyNotFoundExceptionTarget通過將Bean調用的第一個字母從#{TestBean.runTest1}更改爲#{te stBean.runTest1}