Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Prevent file upload when clicking on cancel button

Juraj.K-OracleMay 30 2012 — edited Aug 9 2012
Hello all,

I have a problem with cancelling a form containing file upload field. In short, the upload happens even in case I click on Cancel button. What's the way to prevent "submitting" the form, but letting the server side continue navigating?
In long, I have such form:
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document id="d1" title="File upload">
      <af:form id="f1" usesUpload="true">
        <af:inputFile label="Choose file: " id="if1" required="true"
                      showRequired="false"
                      requiredMessageDetail="You have to choose the file."/>
        <af:commandButton text="Upload" id="cb1" action="submit"/>
        <af:commandButton text="Cancel" id="cb2" immediate="true"
                          action="cancel"/>
      </af:form>
    </af:document>
  </f:view>
</jsp:root>
with very simple unbounded taskflow - action <font face="courier">submit</font> goes to one page (pageFileUploaded), action <font face="courier">cancel</font> to another page (pageCancel).

The problem is that even I click on Cancel the file choosen is being uploaded and just then the pageCancel is shown, which in case of big files or slow connections is not acceptable. How to prevent this? How to show the pageCancel immediately after clicking Cancel button?

Thank you in advance.

Regards,
Rox

P.S.: Using JDeveloper 11.1.1.5.0.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 6 2012
Added on May 30 2012
4 comments
1,334 views