7 Replies Latest reply on Jan 16, 2020 4:14 PM by juquisilva

    File Upload does not work with a4j command button. Is that a bug?

    uesker

      Hi!


      In my web app, I use a data table to iterate over an arraylist. For every item i create a link to submit a file. I,m doing this with a modal panel.


      So, here is a piece of xhtml page.



      <ui:define name="body">
           
           <ui:include src="/questaoPesquisa/modalDefinirArtigosControle.xhtml" />
           
          <h:form id="fillControlForm">
              <rich:panel>
                  <f:facet name="header">#{messages['srprocess.definecontrol.page.title']}</f:facet>
                     <h:outputText value="#{messages['srprocess.definecontrol.page.description']}"/><br/>
                     <rich:spacer height="20px"/>
                     
                     <a4j:outputPanel id="tabelaQuestoesPrimarias">
                       <h:outputText value="#{messages['srprocess.definecontrol.page.primaryquestionstable.description']}"/>
                       <rich:dataTable id="tablePrimaryQuestion" value="#{estudoSecundario.m_EstruturaEstudo.m_ObjetivoPesquisa.m_QuestoesPrimarias}" var="_question">
                            <rich:column>
                                 <f:facet name="header">#{messages['srprocess.definecontrol.page.primaryquestionstable.question']}</f:facet>
                                 #{_question.descricao}
                            </rich:column>
                            <rich:column>
                                 <a4j:commandLink value="#{messages['command.submitbibtex']}" action="#{defineControlAction.displayControlWindow(_question)}"
                                      oncomplete="javascript:Richfaces.showModalPanel('modalPanelArtigoControle')" reRender="definirArtigoControle:modalPanelArtigoControle">
                                      <f:param name="taskId" value="#{taskInstance.id}"/> 
                                 </a4j:commandLink>
                            </rich:column>
                       </rich:dataTable>
                  </a4j:outputPanel>
      



      And here is the modal panel page



      <f:subview id="definirArtigoControle" xmlns="http://www.w3.org/1999/xhtml"
          xmlns:s="http://jboss.com/products/seam/taglib"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:rich="http://richfaces.org/rich"
          xmlns:a4j="http://richfaces.org/a4j">
          
          <rich:modalPanel id="modalPanelArtigoControle" autosized="true">
               <f:facet name="header">#{messages['srprocess.definecontrol.page.assigncontrol.title']}</f:facet>
               <h:form enctype="multipart/form-data">
                    <h:outputText value="#{messages['srprocess.definecontrol.page.assigncontrol.description']}"/><br/>
                     <rich:spacer height="20px"/>
      
                     #{defineControlAction.descQuestaoPesquisa}
                     
                     <rich:spacer height="20px"/>
                     
                     <s:decorate id="artigoControleField" template="/layout/edit.xhtml">
                          <ui:define name="label">#{messages['srprocess.definecontrol.page.bibtex']}</ui:define>
                          <s:fileUpload required="true" data="#{defineControlAction.conteudoBibtex}" fileName="#{defineControlAction.fileName}"
                               contentType="#{defineControlAction.contentType}"/>
                     </s:decorate>
                     
                     <div style="clear: both" />
                     
                     <div class="actionButtons">
                     <h:commandButton value="#{messages['command.assign']}" action="#{defineControlAction.defineControl}" onclick="javascript:Richfaces.hideModalPanel('modalPanelArtigoControle')">
                          <f:param name="taskId" value="#{taskInstance.id}"/>
                     </h:commandButton>
                   <a4j:commandButton value="#{messages['command.assign']}" action="#{defineControlAction.defineControl}"
                        oncomplete="javascript:Richfaces.hideModalPanel('modalPanelArtigoControle')">
                       <f:param name="taskId" value="#{taskInstance.id}"/>
                  </a4j:commandButton>
              </div>               
                     
               </h:form>
               <f:facet name="controls">
                    <h:graphicImage value="/img/close.png" onclick="Richfaces.hideModalPanel('modalPanelArtigoControle')" style="cursor:pointer"/>
                   </f:facet>
          </rich:modalPanel>
      </f:subview>



      When I try to use a4j:commandButton the file is not submited, but when I try with h:commandButton it works. The problem is when I use h:commandButton an exception related to JBPM it´s thrown, event with the use o f:param inside h:commandButton.


      How can I use a4j:commandButton and submit a file or resolve the issue related to taskId on JBPM?


      Here is the exception



      Exception during request processing:
      Caused by javax.el.ELException with message: "java.lang.IllegalStateException: task/process id may not be null"
      
      org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:339)
      org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:348)
      org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
      org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
      org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
      org.jboss.seam.core.Expressions$2.invoke(Expressions.java:175)
      org.jboss.seam.navigation.Page.preRender(Page.java:311)
      org.jboss.seam.navigation.Pages.preRender(Pages.java:351)
      org.jboss.seam.jsf.SeamPhaseListener.preRenderPage(SeamPhaseListener.java:561)
      org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:472)
      org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:148)
      org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:118)
      com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
      org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:86)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
      org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
      org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
      org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
      org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
      org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
      org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
      org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
      org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
      org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
      org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
      org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      java.lang.Thread.run(Unknown Source)
      
      Caused by java.lang.IllegalStateException with message: "task/process id may not be null" 




      Thanks!


        • 1. Re: File Upload does not work with a4j command button. Is that a bug?
          raphaufrj

          Have you ever tried to use a4j:form enctype multipart/form-data and a4j:commandButton ?


          Another detail: Make sure that your modal panel is outside of the main h:form.

          • 2. Re: File Upload does not work with a4j command button. Is that a bug?
            cbensemann

            Both Raphaels comments are good points.


            In addition I have a couple of suggestions.


            Use s:taskId instead of f:param. I'm not sure why it's different but I remember having similar jbpm exceptions when using f:param in some situations.


            <s:taskId value="#{task.id}" />
            



            Is there a reason why you are not using the richfaces fileupload component? One thing I've learnt is that when using some richfaces components on a page its best to use as many of them as you can to help avoid strange behavior.



            Craig

            • 3. Re: File Upload does not work with a4j command button. Is that a bug?
              uesker

              Raphael  Rodrigues wrote on Nov 23, 2010 13:09:


              Have you ever tried to use a4j:form enctype multipart/form-data and a4j:commandButton ?

              Another detail: Make sure that your modal panel is outside of the main h:form.


              Yep... same error..
              I have  awareness of this restriction...

              • 4. Re: File Upload does not work with a4j command button. Is that a bug?
                uesker

                Craig Bensemann wrote on Nov 23, 2010 13:35:


                Both Raphaels comments are good points.

                In addition I have a couple of suggestions.

                Use s:taskId instead of f:param. I'm not sure why it's different but I remember having similar jbpm exceptions when using f:param in some situations.

                <s:taskId value="#{task.id}" />
                



                Is there a reason why you are not using the richfaces fileupload component? One thing I've learnt is that when using some richfaces components on a page its best to use as many of them as you can to help avoid strange behavior.


                Craig


                Hi!


                I tried to use s:taskId but does not work...


                I already tried the richfaces fileupload component, but when I click on upload button an exception it´s thrown - http status 503



                17:23:42,127 WARN  [SeamPhaseListener] uncaught exception, passing to exception handler
                org.jboss.seam.ConcurrentRequestTimeoutException: Concurrent call to conversation
                        at org.jboss.seam.core.Manager.restoreAndLockConversation(Manager.java:644)
                        at org.jboss.seam.core.Manager.restoreConversation(Manager.java:606)
                        at org.jboss.seam.jsf.SeamPhaseListener.afterRestoreView(SeamPhaseListener.java:392)
                        at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:230)
                        at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:196)
                        at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
                        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)
                        at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:103)
                        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
                        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                        at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
                        at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                        at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
                        at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
                        at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
                        at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                        at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
                        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
                        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
                        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
                        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
                        at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
                        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                        at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
                        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
                        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
                        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
                        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                        at java.lang.Thread.run(Unknown Source)
                17:23:42,130 ERROR [CachedConnectionValve] Application error: Faces Servlet did not complete its transaction
                




                • 5. Re: File Upload does not work with a4j command button. Is that a bug?
                  uesker

                  As you can see... I´m trying with both components and buttons but the error persists



                      <rich:modalPanel id="modalPanelArtigoControle" autosized="true">
                           <f:facet name="header">#{messages['srprocess.definecontrol.page.assigncontrol.title']}</f:facet>
                           <h:form enctype="multipart/form-data">
                                <h:outputText value="#{messages['srprocess.definecontrol.page.assigncontrol.description']}"/><br/>
                                 <rich:spacer height="20px"/>
                  
                                 #{defineControlAction.descQuestaoPesquisa}
                                 
                                 <rich:spacer height="20px"/>
                                 
                                 <s:decorate id="artigoControleField" template="/layout/edit.xhtml">
                                      <ui:define name="label">#{messages['srprocess.definecontrol.page.bibtex']}</ui:define>
                                      
                                      <rich:fileUpload fileUploadListener="#{defineControlAction.uploadListener}"/>
                                      
                                      <s:fileUpload required="true" data="#{defineControlAction.conteudoBibtex}" fileName="#{defineControlAction.fileName}"
                                           contentType="#{defineControlAction.contentType}">
                                           <s:conversationPropagation type="none"/>
                                      </s:fileUpload>
                                 </s:decorate>
                                 
                                 <div style="clear: both" />
                                 
                                 <div class="actionButtons">
                                 <h:commandButton value="#{messages['command.assign']}" action="#{defineControlAction.defineControl}" onclick="javascript:Richfaces.hideModalPanel('modalPanelArtigoControle')">
                                      <s:taskId name="taskId" value="#{taskInstance.id}"/>
                                 </h:commandButton>
                                 
                               <a4j:commandButton value="#{messages['command.assign']}" action="#{defineControlAction.defineControl}"
                                    oncomplete="javascript:Richfaces.hideModalPanel('modalPanelArtigoControle')">
                                   <f:param name="taskId" value="#{taskInstance.id}"/>
                              </a4j:commandButton>
                          </div>               
                                 
                           </h:form>
                           <f:facet name="controls">
                                <h:graphicImage value="/img/close.png" onclick="Richfaces.hideModalPanel('modalPanelArtigoControle')" style="cursor:pointer"/>
                               </f:facet>
                      </rich:modalPanel>



                  • 6. Re: File Upload does not work with a4j command button. Is that a bug?
                    uesker

                    I made some modifications and now i´m facing another problem. I´m using rich faces file upload component. When I click on upload button, the upload listener method it´s called correctly, but the item.getData it´s null. All other parameters are correct. This behavior it´s still related with modal panel? How can I solve this?



                    <f:subview id="definirArtigoControle" xmlns="http://www.w3.org/1999/xhtml"
                        xmlns:s="http://jboss.com/products/seam/taglib"
                        xmlns:ui="http://java.sun.com/jsf/facelets"
                        xmlns:f="http://java.sun.com/jsf/core"
                        xmlns:h="http://java.sun.com/jsf/html"
                        xmlns:rich="http://richfaces.org/rich"
                        xmlns:a4j="http://richfaces.org/a4j">
                        
                        
                             <rich:modalPanel id="modalPanelArtigoControle" autosized="true">
                                  <f:facet name="header">#{messages['srprocess.definecontrol.page.assigncontrol.title']}</f:facet>
                                  <a4j:form enctype="multipart/form-data">
                                       <h:outputText value="#{messages['srprocess.definecontrol.page.assigncontrol.description']}"/><br/>
                                        <rich:spacer height="20px"/>
                         
                                        #{defineControlAction.descQuestaoPesquisa}
                                        
                                        <rich:spacer height="20px"/>
                                        
                                        <s:decorate id="artigoControleField" template="/layout/edit.xhtml">
                                             <ui:define name="label">#{messages['srprocess.definecontrol.page.bibtex']}</ui:define>
                                             
                                             <rich:fileUpload fileUploadListener="#{defineControlAction.uploadListener}"
                                                  immediateUpload="false"  allowFlash="true" ajaxSingle="true" disabled="false"
                                                  autoclear="true" onfileuploadcomplete="javascript:Richfaces.hideModalPanel('modalPanelArtigoControle')" >
                                             </rich:fileUpload>
                                             
                                        </s:decorate>
                                        
                                        <div style="clear: both" />
                                        
                                  <f:facet name="controls">
                                       <h:graphicImage value="/img/close.png" onclick="Richfaces.hideModalPanel('modalPanelArtigoControle')" style="cursor:pointer"/>
                                      </f:facet>
                                      </a4j:form>
                             </rich:modalPanel>
                            
                    </f:subview>



                    I have added the following line in components.xml



                    <web:multipart-filter create-temp-files="false" max-request-size="1000000" url-pattern="*.seam" />





                    • 7. Re: File Upload does not work with a4j command button. Is that a bug?
                      juquisilva

                      Your comment helped me a lot! Thanks!