Announcement Announcement Module
Collapse
No announcement yet.
Problem between Multipart and spring web flow. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem between Multipart and spring web flow.

    (Move this thread to the appropiated are if needed)

    I have a little problem between MultiPart files and the spring web flow. As far as I know, MultiPart is not Serializable and this thing is making that my applicattion crashes. Ill try to explain what's the concrete problem. First of all, Im at home right now and I don't have the implementation and configuration here, so Im writing what I remember that I have coded and that's not what I have exactly in my code. Sorry for some code errors in xml files, but I don't think that all the code is necessary for explaining my problem.
    One last thing to go, Im using the file upload libraries from apache jakarta commons.

    I have this class:
    Code:
    RangeRequest class {
    
        private Integer code = new Integer();
        private String description = new String();
        ...
        private MultiPart multiPartFile;
        /* Getters and Setters for all attributes */
    
    }
    In my .jsp, I have something like this:
    HTML Code:
    <table>
    <form method="post" action="?" name="formSgd" enctype="multipart...">
       <input hidden name="_eventId" value=""/>
       <input hidden name="_flowExecutionId" value="${flowExecutionId}"/>
       <!-- more inputs and text -->
       <input type="file" name="fileRangeRequest" value="" onClick="blur()"/>
    </form>
    </table>
    I presume that my rangeRequestWebFlow.xml, where is declared the web flow of my functionality, is fine cause, if I comment the enctype part the application runs great.

    The problem is that Ive defined a last <view-state> where I want to tell to the logged user that the transaction was fine. I have something like this:
    Code:
    ... More action-states
    
    <action-state id="insertFile">
       <action bean="rangeRequestAction"/>
       <transition on="success" to="viewFinishRangeRequest"/>
       <transition on="error" to="errorPage"/>
    </action-state>
    
    <!-- 
          Request is presented to the user. Here we show to the user
          that the transaction was fine and some attributes got from
          the form and the code that is returned when inserting the
          request into the DB 
     -->
    * <view-state id="viewFinishRangeRequest" view="viewFinish">
    *   <transition on="finish" to="finishView"/>
    * </view-state>
    
    <end-state id="finishView" view="home"/>
    ...
    I have to have something like this to bind properly the data which is got in the form and the class RangeRequest:
    setFormObject(RangeRequest.class);
    There's no problem at the beggining, cause MultiPart is not initialize (I pressume) but when the uploading takes part, MultiPart is filled and I have a full object. So, when spring tries to follow the next step defined in the flow scope (the one marked with an * at the beggining of the line), an error occurs cause spring tries to set in the FlowScope the MultiPart object and, like I mentioned in the beggining of this thread, MultiPart is not Serializable and a NotSerializableException happens, cause all the objects and attributes set in the flow Scope must be serializable.
    Do you understand what is happening to me? Is there anyway to fix this problem?. I think that I have to tell spring that in the last view it doesn't have to set the MultiPart attribute at least or to set the whole RangeRequest object to null and set only the elements that I want in the flow scope (maybe code of insertion, description, file name, and so on).

    Well I hope that you can help me with this problem.

  • #2
    [QUOTE=Lasneyx]
    Code:
    RangeRequest class {
    
        private Integer code = new Integer();
        private String description = new String();
        ...
        private MultiPart multiPartFile;
        /* Getters and Setters for all attributes */
    
    }
    I don't be able to test this till monday but I think that the solution is to change
    private MultiPart multiPartFile;
    by
    private CommonsMultiPart cMultiPartFile;
    Commons is Serializable and spring won't tell me nothing about the non serilizability of this attribute, will it?
    Can anybody confirm me this solution?

    Thanks

    Comment

    Working...
    X