diff options
author | Tomi Virtanen <tltv@vaadin.com> | 2013-12-09 13:44:27 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-01-07 09:27:08 +0000 |
commit | 0579fba63048ffa8daa22db5243a149e67f73594 (patch) | |
tree | b59603dcbe436e2c5433e44120bfabe3881dd915 /client | |
parent | 0b95f8d6f6e3f278b51c0242e8ce2dfc82ed829e (diff) | |
download | vaadin-framework-0579fba63048ffa8daa22db5243a149e67f73594.tar.gz vaadin-framework-0579fba63048ffa8daa22db5243a149e67f73594.zip |
Upload control with empty selection (#9602)
Event is now sent on submit even if no file is selected. Removed forceSubmit UIDL attribute and replaced it with a UploadClientRpc call. Added TestBench3 test.
Change-Id: Id32b82532ec34e61a9c0718413fd1755015d2c30
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VUpload.java | 7 | ||||
-rw-r--r-- | client/src/com/vaadin/client/ui/upload/UploadConnector.java | 14 |
2 files changed, 15 insertions, 6 deletions
diff --git a/client/src/com/vaadin/client/ui/VUpload.java b/client/src/com/vaadin/client/ui/VUpload.java index c08d75e9b7..8e55387d39 100644 --- a/client/src/com/vaadin/client/ui/VUpload.java +++ b/client/src/com/vaadin/client/ui/VUpload.java @@ -295,10 +295,13 @@ public class VUpload extends SimplePanel { /** For internal use only. May be removed or replaced in the future. */ public void submit() { - if (fu.getFilename().length() == 0 || submitted || !enabled) { - VConsole.log("Submit cancelled (disabled, no file or already submitted)"); + if (submitted || !enabled) { + VConsole.log("Submit cancelled (disabled or already submitted)"); return; } + if (fu.getFilename().length() == 0) { + VConsole.log("Submitting empty selection (no file)"); + } // flush possibly pending variable changes, so they will be handled // before upload client.sendPendingVariableChanges(); diff --git a/client/src/com/vaadin/client/ui/upload/UploadConnector.java b/client/src/com/vaadin/client/ui/upload/UploadConnector.java index 937ff438ac..989a913adc 100644 --- a/client/src/com/vaadin/client/ui/upload/UploadConnector.java +++ b/client/src/com/vaadin/client/ui/upload/UploadConnector.java @@ -22,12 +22,22 @@ import com.vaadin.client.UIDL; import com.vaadin.client.ui.AbstractComponentConnector; import com.vaadin.client.ui.VUpload; import com.vaadin.shared.ui.Connect; +import com.vaadin.shared.ui.upload.UploadClientRpc; import com.vaadin.ui.Upload; @Connect(Upload.class) public class UploadConnector extends AbstractComponentConnector implements Paintable { + public UploadConnector() { + registerRpc(UploadClientRpc.class, new UploadClientRpc() { + @Override + public void submitUpload() { + getWidget().submit(); + } + }); + } + @Override public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { if (!isRealUpdate(uidl)) { @@ -37,10 +47,6 @@ public class UploadConnector extends AbstractComponentConnector implements getWidget().t.schedule(400); return; } - if (uidl.hasAttribute("forceSubmit")) { - getWidget().submit(); - return; - } getWidget().setImmediate(getState().immediate); getWidget().client = client; getWidget().paintableId = uidl.getId(); |