在datatable </customobject>中使用List <customobject>时出现NumberFormatException

时间:2012-06-13 04:12:42

标签: java jsf datatable nullpointerexception icefaces

尝试在数据表中显示List时遇到NumberFormatException。我知道发生此异常的一般原因,但无法确定它在我的情况下适用的位置。

这是我的冰:数据表显示代码

<ice:dataTable id="transformations" var="transformationList" width="700"
value="#{ShowStatusBean.transformationStatusList}" rows="10"    
partialTriggers="refreshButton"  autoSubmit="true">

<ice:column>
<ice:outputText value="#{transformationList.businessDate}" />
</ice:column>

<ice:column>
<ice:outputText value="#{transformationList.service}" />
</ice:column>

<ice:column>
<ice:outputText value="#{transformationList.status}" />
</ice:column>

</ice:dataTable>

我的支持bean代码

public List<TransformationBean> getTransformationStatusList() {
    transformationStatusList = new ArrayList<TransformationBean>();
    transformationStatusList.add(new TransformationBean("2012-01-01", "serviceName", "status1"));
    transformationStatusList.add(new TransformationBean("2012-01-02", "serviceName2", "status2"));
    return transformationStatusList;
}

最后是堆栈跟踪

    23:59:57 ERROR [f-tuning)'] D2DFaceletViewHandler     - Problem in renderResponse: For input string: "businessDate"
java.lang.NumberFormatException: For input string: "businessDate"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    at java.lang.Integer.parseInt(Integer.java:449)
    at java.lang.Integer.parseInt(Integer.java:499)
    at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:138)
    at com.sun.el.parser.AstValue.getValue(AstValue.java:96)
    at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:183)
    at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
    at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:56)
    at javax.faces.component.UIOutput.getValue(UIOutput.java:80)
    at com.icesoft.faces.renderkit.dom_html_basic.OutputTextRenderer.encodeEnd(OutputTextRenderer.java:91)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:539)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:369)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
    at com.icesoft.faces.component.ext.renderkit.TableRenderer.encodeChildren(TableRenderer.java:896)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:357)
    at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
    at com.icesoft.faces.component.util.CustomComponentUtils.renderChild(CustomComponentUtils.java:338)
    at com.icesoft.faces.component.panelpopup.PanelPopupRenderer.encodeBegin(PanelPopupRenderer.java:240)
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:515)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:355)
    at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:357)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
    at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:357)
    at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
    at com.icesoft.faces.component.util.CustomComponentUtils.renderChild(CustomComponentUtils.java:338)
    at com.icesoft.faces.component.paneltabset.PanelTabSetRenderer.writeTabCell(PanelTabSetRenderer.java:983)
    at com.icesoft.faces.component.paneltabset.PanelTabSetRenderer.encodeEnd(PanelTabSetRenderer.java:422)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:539)
    at javax.faces.component.UIData.encodeEnd(UIData.java:573)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:369)
    at com.icesoft.faces.renderkit.dom_html_basic.GridRenderer.encodeChildren(GridRenderer.java:207)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:357)
    at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:357)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
    at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:357)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
    at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:364)
    at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:95)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
    at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:490)
    at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:495)
    at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:495)
    at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:495)
    at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:495)
    at com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:281)
    at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:155)
    at com.icesoft.faces.application.ViewHandlerProxy.renderView(ViewHandlerProxy.java:70)
    at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
    at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:51)
    at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:171)
    at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:112)
    at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:65)
    at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:48)
    at com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:58)
    at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:55)
    at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:77)
    at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:55)
    at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:192)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:67)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

我的TransformationBean

public class TransformationBean{

    private String businessDate;
    private String service;
    private String status;

    // constructor 
    // getter and setters
    }

我研究了这个问题并找到了很多回复。但它确实看起来我没有做任何这些错误..所以不确定我错过了什么。 这些是我发现的关于同一问题的其他链接。

Number format exception when returning values from database(JPA)

NumberFormatException for input String

http://jforum.icesoft.org/JForum/posts/list/16645.page

所有这些都提到List&lt;&gt;从java代码返回是一个 Object []的列表,这就是为什么它试图通过将属性视为索引属性来获取数组条目。但是,从我的代码中,它清楚我没有返回一个List of Object [],但是一个正确的定义列表

我还测试了JUNit测试用例中的java代码,并验证了返回类型是TransformationBean对象的列表。

我不能正确做什么,伙计们?

1 个答案:

答案 0 :(得分:0)

我能够解决问题。不知道问题是什么。我刚创建了一个包含我的xhtml显示代码的新文件,其中包含相同的信息集。我改变的唯一的事情是将var名称更改为bean。

    <ice:dataTable id="transformations" var="bean" width="700"
value="#{ShowStatusBean.transformationStatusList}" rows="10"    
partialTriggers="refreshButton"  autoSubmit="true">

<ice:column>
<ice:outputText value="#{bean.businessDate}" />
</ice:column>

<ice:column>
<ice:outputText value="#{bean.service}" />
</ice:column>

<ice:column>
<ice:outputText value="#{bean.status}" />
</ice:column>

</ice:dataTable>`

它开始工作..没有意义..也许应用服务器缓存了一些不正确的先前版本..但看起来我的代码一直都是正确的。