-2

将 f:ajax 标记添加到我的 jsf 页面,希望使用 ajax

<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
4

1 回答 1

1

通过将属性设为私有并从参数 getter 和 setter 中删除静态修饰符来解决 Property not found 错误:

    private static String runTest1Result;  

public String getRunTest1Result() {
    return runTest1Result;
}

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

通过将 Bean 调用的首字母的大小写从 #{TestBean.runTest1} 更改为 #{testBean.runTest1} 解决了初始 javax.el.PropertyNotFoundExceptionTarget Unreachable 'TestBean'

于 2012-12-06T12:39:23.903 回答