Announcement Announcement Module
Collapse
No announcement yet.
Spring Web Flow + Excel download Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Web Flow + Excel download

    Hello,

    I am new to Spring webflow (and Spring). I use Spring 2.5, Webflow 2.0.8 and Tiles 2.0.5. My application have to generate an excel file for download when the user push the "export" button on my view. I implemented the given solution in the reference documentation http://static.springsource.org/sprin...l/ch05s07.html paragraph streaming actions. Unfortunately, it does not work well.

    My flow :
    Code:
    <view-state id="syntheseView" model="syntheseModel" view="syntheseJsp">
        <transition on="return" to="searchView" />
        <transition on="exporter">
            <evaluate expression="excelService"/>   
        </transition>
    </view-state>
    The class which generates the excel file, is :
    Code:
    public class ExcelService extends AbstractAction {
     
        @Override
        protected Event doExecute(RequestContext context) throws Exception {
            HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getNativeResponse();
            XlsFileManager xlsFileManager = new XlsFileManager();
            MyModel myModel = (ModeleMetier)context.getFlowScope().get("myModel");
            HSSFWorkbook wb = xlsFileManager.createXlsStream(myModel);
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("Content-Disposition","attachment; filename=fichiertoutbeantoutpropre.xls; charset=cp1252");
            ServletOutputStream sos = response.getOutputStream();
            wb.write(sos);
            sos.close();
            context.getExternalContext().recordResponseComplete();
            return success();
        }
    }
    declaration of excelService :
    Code:
    <bean id="excelService" class="fr.myapplication.service.impl.ExcelService" autowire="byName" />
    Then I tested my application. On the synthese wiew, I push the "export" button. The Excel file is generated and the download works correctly. Then, if I push any action on my view (the "export" or the "return" button", I get this error :
    Code:
    2010/06/03-18:44:58 [ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)' org.springframework.web.servlet.DispatcherServlet DEBUG Could not complete request
    org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'syntheseView' of flow 'consultation'
        at org.springframework.webflow.engine.impl.FlowExecutionImpl.wrap(FlowExecutionImpl.java:569)
        at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:263)
        at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:163)
        at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
        at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
        at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.ui.preauth.AbstractPreAuthenticatedProcessingFilter.doFilterHttp(AbstractPreAuthenticatedProcessingFilter.java:69)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3393)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(Unknown Source)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2140)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2046)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
    Caused by: java.lang.ClassCastException: [Ljava.lang.String;
        at org.springframework.web.util.WebUtils.findParameterValue(WebUtils.java:565)
        at org.springframework.webflow.mvc.view.AbstractMvcView.determineEventId(AbstractMvcView.java:317)
        at org.springframework.webflow.mvc.view.AbstractMvcView.getEventId(AbstractMvcView.java:282)
        at org.springframework.webflow.mvc.view.AbstractMvcView.userEventQueued(AbstractMvcView.java:191)
        at org.springframework.webflow.engine.ViewState.resume(ViewState.java:195)
        at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
        at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
        ... 38 more
    2010/06/03-18:44:58 [ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)' org.springframework.security.context.HttpSessionContextIntegrationFilter DEBUG SecurityContextHolder now cleared, as request processing completed
    <3 juin 2010 18 h 44 CEST> <Error> <HTTP> <BEA-101017> <[weblogic.servlet.internal.WebAppServletContext@52d188 - appName: '_appsdir_myApplication_dir', name: 'myApplication', context-path: '/myApplication'] Root cause of ServletException.
    org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'syntheseView' of flow 'consultation'
        at org.springframework.webflow.engine.impl.FlowExecutionImpl.wrap(FlowExecutionImpl.java:569)
        at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:263)
        at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:163)
        at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        Truncated. see log file for complete stacktrace
    java.lang.ClassCastException: [Ljava.lang.String;
        at org.springframework.web.util.WebUtils.findParameterValue(WebUtils.java:565)
        at org.springframework.webflow.mvc.view.AbstractMvcView.determineEventId(AbstractMvcView.java:317)
        at org.springframework.webflow.mvc.view.AbstractMvcView.getEventId(AbstractMvcView.java:282)
        at org.springframework.webflow.mvc.view.AbstractMvcView.userEventQueued(AbstractMvcView.java:191)
        at org.springframework.webflow.engine.ViewState.resume(ViewState.java:195)
        Truncated. see log file for complete stacktrace
    Can anyone help me ?
    I looked for topics in this forums about the ClassCastException and the file download but it doesn't help me.

    Thanks.
    Last edited by pika822; Jun 9th, 2010, 11:06 AM. Reason: add Tiles and tags
Working...
X