如何确保JSF意识到特定属性是java.lang.String类型?

时间:2013-07-05 02:40:23

标签: java jsf tomcat6 facelets

不确定以下代码发生了什么:

<h:dataTable value="{scheduler.quartzJobList}" var="q"
    styleClass="quartz-table" headerClass="quartz-table-header"
    rowClasses="quartz-table-odd-row,quartz-table-even-row">

    <h:column>
        <f:facet name="header">Job Name</f:facet>
        #{q.jobName}
    </h:column>

只要我尝试在Tomcat6上呈现它就失败了。这是堆栈跟踪:

javax.el.ELException: /quartzjob.xhtml: Property 'jobName' not found on type java.lang.String
    at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:88)
    at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)
    at com.sun.faces.renderkit.html_basic.TableRenderer.renderRow(TableRenderer.java:385)
    at com.sun.faces.renderkit.html_basic.TableRenderer.encodeChildren(TableRenderer.java:162)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:885)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:885)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:447)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    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:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)

这是我构建动作bean的方法:

@ManagedBean(name="scheduler")
@SessionScoped
public class SchedulerBean implements Serializable {

    private static final long serialVersionUID = 1L;

    private Scheduler scheduler;

    private List<QuartzJob> quartzJobList = new ArrayList<QuartzJob>();

    public static class QuartzJob {

       private String jobName;

       // getter and setter of jobName
    }
}

如果我删除#{q.jobName}它只是工作正常。以下是我的项目中使用的库:

  • EL-IMPL-2.2.jar
  • jsf-api-2.1.23.jar
  • jsf-impl-2.1.23.jar
  • JS​​TL-1.2.jar
  • JS​​F的API-2.0.1.jar
  • JS​​F的参数impl-2.0.1.jar

1 个答案:

答案 0 :(得分:2)

您在

中缺少#
<h:dataTable value="{scheduler.quartzJobList}" var="q"

应该是,

 <h:dataTable value="#{scheduler.quartzJobList}" var="q"

并确保您拥有quartzJobList的吸气剂。