4 Replies Latest reply on Jun 9, 2016 11:13 AM by Sudha Raj

    rich:fileUpload is not working in rich:popUpPanel

    Sudha Raj Newbie

      I am migrating richfaces3.x to richfaces 4, and I am using richfaces 4.5.15.Final version, JSF 2.1.28, Jboss EAP 6.3.0.

       

      When I have tried to upload a file in rich:popUpPanel, I am getting the following error, I click on the Add button then browse and select the file and immediately I am getting the following error. My code I have added immediate=true.

       

      13:54:19,826 ERROR [com.wachovia.apps.amaster.util.CustomExceptionHandler] (http-/127.0.0.1:8080-1) Exception caught: javax.faces.FacesException: java.lang.StringIndexOutOfBoundsException: String index out of range: -1

              at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:257) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]

              at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]

              at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]

              at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]

              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

              at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]

              at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]

              at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]

              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.4.8.Final-redhat-4.jar:7.4.8.Final-redhat-4]

              at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_97]

      Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1

              at java.lang.String.substring(String.java:1911) [rt.jar:1.7.0_97]

              at com.sun.faces.renderkit.ServerSideStateHelper.getState(ServerSideStateHelper.java:302) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]

              at com.sun.faces.renderkit.ResponseStateManagerImpl.getState(ResponseStateManagerImpl.java:100) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]

              at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:534) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]

              at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:142) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]

              at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:301) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]

              at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:301) [jboss-jsf-api_2.1_spec-2.1.28.Final-redhat-1.jar:2.1.28.Final-redhat-1]

              at org.richfaces.application.GlobalResourcesViewHandler.restoreView(GlobalResourcesViewHandler.java:179) [richfaces-core-4.5.15.Final.jar:4.5.15.Final]

              at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:192) [jsf-impl-2.1.28.redhat-3.jar:2.1.28.redhat-3]

       

      Here is my code,

       

      <rich:popupPanel id="modelsuploadpanel" width="425" height="300" keepVisualState="false" domElementAttachment="form" modal="true">

        <f:facet name="header">

        <h:panelGroup>

        <h:outputText value="Multiple Model Upload"/>

        </h:panelGroup>

        </f:facet>

        <f:facet name="controls">

        <h:graphicImage value="img/close.png">

      <rich:componentControl target="modelsuploadpanel" operation="hide" event="click" />

        </h:graphicImage>

        </f:facet>

       

      <h:form id="ModelsUploadForm" enctype="multipart/form-data">

      <rich:messages style="color:red;"></rich:messages>

      <f:view>

      <br /><br />

      <table id="exportModelTab">

      <tr><td/><td/></tr>

      <tr>

      <td><h:outputLabel styleClass="Label" value="Select Model File" for="modellistfile" /></td>

      <td>

      <rich:fileUpload id="modellistfile" styleClass="fileUploadInput" data="#{bulkModelUpload.modelsFile}" addLabel="Browse"

      immediateUpload="true" maxFilesQuantity="1" listHeight="45px" fileUploadListener="#{fileUploadBean.listener}"/>

      </td></tr>

      <tr/> <tr>

      <td>

      <h:commandButton styleClass="Button" value="Upload File"

      reRender="modelsuploadpanel" id="btn_upload"

      oncomplete="#{rich:component('modeluploadpanel')}.show()"

      action="#{bulkModelUpload.updateModels}">

      </h:commandButton>

      </td><td/> </tr>

      </table>

      </f:view>

      </h:form> 

      <richext:spacer height="20"/>

        </rich:popupPanel>

       

      Can you please guide me what is wrong in my code?

       

      Notes: There is no issue with the file that I have tried to upload, because the same file is working fine in richface3.x.