2013-08-03 137 views
0

我有一個問題,我使用primefaces的成分數據表,以顯示產品的列表:DATATABLE primefaces java.lang.StringIndexOutOfBoundsException

<h:form id="id_form"> 

     <p:dataTable var="prod" value="#{produitBean.listeProduit}" widgetVar="grilleProduit"> 
      <f:facet name="header"> 
       Liste des produits 
      </f:facet> 

      **<p:column> 
       <f:facet name="header"> 
        Aperçu 
       </f:facet> 
       <p:graphicImage value="#{prod.urlImg}" /> 
      </p:column>** 
      <p:column > 
       <f:facet name="header"> 
        Nom 
       </f:facet> 
       <h:outputText value="#{prod.libelle}" /> 
      </p:column> 

      <p:column > 
       <f:facet name="header"> 
        Déails 
       </f:facet> 
       <h:outputText value="#{prod.details}" /> 
      </p:column> 


      </p:dataTable> 


    </h:form> 

問題是與該產品的圖像,當我添加圖像的列我有一個java.lang.StringIndexOutOfBoundsException:字符串索引超出範圍:0 當我刪除它的作品。我不明白這個錯誤的意思。 以下是堆棧跟蹤:

java.lang.StringIndexOutOfBoundsException: String index out of range: 0 
at java.lang.String.charAt(String.java:658) 
at com.sun.faces.application.view.MultiViewHandler.getResourceURL(MultiViewHandler.java:341) 
at javax.faces.application.ViewHandlerWrapper.getResourceURL(ViewHandlerWrapper.java:244) 
at org.jboss.weld.jsf.ConversationAwareViewHandler.getResourceURL(ConversationAwareViewHandler.java:143) 
at org.primefaces.renderkit.CoreRenderer.getResourceURL(CoreRenderer.java:76) 
at org.primefaces.component.graphicimage.GraphicImageRenderer.getImageSrc(GraphicImageRenderer.java:84) 
at org.primefaces.component.graphicimage.GraphicImageRenderer.encodeEnd(GraphicImageRenderer.java:45) 
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875) 
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764) 
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760) 
at org.primefaces.component.datatable.DataTableRenderer.encodeCell(DataTableRenderer.java:808) 
at org.primefaces.component.datatable.DataTableRenderer.encodeRow(DataTableRenderer.java:773) 
at org.primefaces.component.datatable.DataTableRenderer.encodeTbody(DataTableRenderer.java:651) 
at org.primefaces.component.datatable.DataTableRenderer.encodeRegularTable(DataTableRenderer.java:234) 
at org.primefaces.component.datatable.DataTableRenderer.encodeMarkup(DataTableRenderer.java:196) 
at org.primefaces.component.datatable.DataTableRenderer.encodeEnd(DataTableRenderer.java:82) 
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875) 
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764) 
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168) 
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) 
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757) 
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760) 
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760) 
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402) 
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) 
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288) 
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) 
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.StandardWrapper.service(StandardWrapper.java:1550) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) 
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161) 
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) 
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317) 
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195) 
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860) 
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757) 
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056) 
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229) 
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) 
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) 
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) 
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) 
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) 
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) 
at com.sun.grizzly.ContextTask.run(ContextTask.java:71) 
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) 
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) 
at java.lang.Thread.run(Thread.java:724) 

感謝您的幫助。

+0

'urlImg'的價值是什麼?向我們展示返回'urlImg'的後端bean。 – Manuel

回答

0
at java.lang.String.charAt(String.java:658) 
at com.sun.faces.application.view.MultiViewHandler.getResourceURL(MultiViewHandler.java:341) 

看起來像圖像的URL是一個空字符串。檢查退貨prod.urlImg