1 Reply Latest reply on Oct 9, 2007 4:47 PM by stephen.friedrich

    s:fileUpload doesn't preserve pending value after immediate

    tynor

      Seam 2.0.0.CR1

      I have a form containing several h:inputText's, a s:fileUpload and an h:commandButton that is used to add an item to a server-side Set, which is then used to draw a dataTable on the facelet. (I'm in a manually flushed transaction:

      @Begin(flushMode=FlushModeType.MANUAL, join=true)
      


      I use this sort of button on several forms without any trouble, but I'm having problems when there is an s:fileUpload control on the form -- when the button action fires and the screen refreshes, all the other controls (select boxes, text inputs, etc.) preserve their as-yet-unpersisted values, but the filename selected by the file upload control is cleared.

      Is this a bug in s:fileUpload? Can I workaround somehow?

      <s:decorate id="txtDecoration" template="/WEB-INF/facelets/templates/edit.xhtml">
       <ui:define name="label">Text</ui:define>
       <h:inputText id="txt" value="#{myHome.instance.txt}"/>
      </s:decorate>
      <s:decorate id="fileDecoration" template="/WEB-INF/facelets/templates/edit.xhtml">
       <ui:define name="label">File</ui:define>
       <s:fileUpload id="file" data="#{myHome.data}" required="true"
       contentType="#{myHome.contentType}"
       fileName="#{myHome.fileName}" accept="application/pdf" />
      </s:decorate>
      <s:decorate id="addDecoration" template="/WEB-INF/facelets/templates/edit.xhtml">
       <h:commandButton id="add" value="Add" immediate="true"
       action="#{myHome.addItem}"/>
      </s:decorate>
      ...
      



        • 1. Re: s:fileUpload doesn't preserve pending value after immedi
          stephen.friedrich

          No way to get around it. I have seen an application (Jira)
          that adds a message underneath the upload text field like "Path was lost during reload. Please enter again.". That's probably the best you can do.

          If you really would find a way around this limitation you would be making headlines on many security sites and be the cause of the next minor release of a web browser version.