Announcement Announcement Module
Collapse
No announcement yet.
Dealing with file uploads correctly Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dealing with file uploads correctly

    Hallo,

    I implemented a Fileupload as described in the reference-manual:

    with for example a kind auf this view-state:

    Code:
    <view-state id="uploadFile" model="uploadFileHandler">
        <var name="fileUploadHandler" class="org.springframework.webflow.samples.booking.FileUploadHandler" />
        <transition on="upload" to="finish" >
            <evaluate expression="fileUploadHandler.processFile()"/>
        </transition>
        <transition on="cancel" to="finish" bind="false"/>
    </view-state>
    <view-state id="uploadFile" model="uploadFileHandler">
    <var name="fileUploadHandler" class="org.springframework.webflow.samples.booking .FileUploadHandler" />
    <transition on="upload" to="finish" >
    <evaluate expression="fileUploadHandler.processFile()"/>
    </transition>
    <transition on="cancel" to="finish" bind="false"/>
    </view-state>

    Than i configured a Multipart-Resolver in dispatcher-servlet.xml as follows:

    Code:
      <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <property name="maxUploadSize" value="41943040"/>
      </bean>
    When a user uploads a file that is bigger than the defined size a Execption ist being thrown as expected. But I do not find a way to react on this exception. Of course I want to display the same state again with a suitable error-message.

    So my first try was, to add a transition in the view-state like this

    Code:
      <transition on-exception="...MultipartException" to="uploadFile" />
    But that did not work. With and without this transition the Exception gets propagated to the Browser.

    What ist best or at least the working practice here?

    Regards,
    Marc
Working...
X