Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Multiple FileItem Issue

    Hello ,

    We are having issue trying to save a form with 2 FileItems. Only one file gets to the server .
    Here is our client side code
    Code:
    final TextItem idItem = new TextItem("id", "id");
    idItem.setVisible(false);
    	
    final FileItem logoFileItem = new FileItem("logo", "Logo");
    final FileItem defaultLogoFileItem = new FileItem("defaultLogo", "Default Logo");
    
    dynamicForm.setItems(idItem, logoFileItem, defaultLogoFileItem);
    DMI file...
    Code:
    <fields>
    	<field name="id" type="string" hidden="true" primaryKey="true" />
    	<field name="logo" type="imageFile" title="Logo File" required="false" />
    	<field name="defaultLogo" type="imageFile" title="Default Logo File" required="false" />
    </fields>

    On the server side
    List<ISCFileItem> uploadedFiles = dsRequest.getUploadedFiles();

    always returns ONLY ONE file ( instead of two).


    Please let us know if you need more info.

    Thanks,
    Stonebranch

    p.s. We are using SmartGWTEE2.1

    #2
    This is expected behavior for FileItems, because each is created as a separate HTML <form>. This is what allows other form items to be redrawn for validation errors, showing and hiding fields, etc, without disturbing the user-entered value in a FileItem, which is important since you can re-create an upload control without dropping the value (security constraint).

    There is a MultiFileItem in SmartClient, but it doesn't yet exist in SmartGWT. Essentially it's approach is to manage several DynamicForms each with one FileItem, and submit them in series. This is also the right thing to do for your use case.

    Comment

    Working...
    X