-2

added f:ajax tag to my jsf page, with the hopes of using ajax

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

my bean:

@ManagedBean
@RequestScoped
public class TestBean implements Serializable {

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


}

had been working before added f:ajax tag

any ideas what I am doing wrong and how to fix it?

following error message:

An Error Occurred:

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
4

1 に答える 1

1

プロパティをプライベートにし、パラメータのゲッターとセッターから静的修飾子を削除することで、プロパティが見つからないというエラーが解決されました。

    private static String runTest1Result;  

public String getRunTest1Result() {
    return runTest1Result;
}

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

最初のjavax.el.PropertyNotFoundExceptionTargetUnreachable'TestBean'は、Bean呼び出しの最初の文字の大文字と小文字を#{TestBean.runTest1}から#{testBean.runTest1}に変更することで解決されました

于 2012-12-06T12:39:23.903 に答える