Browse Source

fixes #4654, added virtual client side synchronization for UI check that happens after the upload started event

svn changeset:13085/svn branch:6.3
tags/6.7.0.beta1
Matti Tahvonen 14 years ago
parent
commit
c1608eea9d

+ 9
- 1
src/com/vaadin/terminal/gwt/client/ui/VUpload.java View File



private com.google.gwt.dom.client.Element synthesizedFrame; private com.google.gwt.dom.client.Element synthesizedFrame;


private int nextUploadId;

public VUpload() { public VUpload() {
super(com.google.gwt.dom.client.Document.get().createFormElement()); super(com.google.gwt.dom.client.Document.get().createFormElement());


if (client.updateComponent(this, uidl, true)) { if (client.updateComponent(this, uidl, true)) {
return; return;
} }
if (uidl.hasAttribute("notStarted")) {
t.schedule(400);
return;
}
setImmediate(uidl.getBooleanAttribute("immediate")); setImmediate(uidl.getBooleanAttribute("immediate"));
this.client = client; this.client = client;
paintableId = uidl.getId(); paintableId = uidl.getId();
nextUploadId = uidl.getIntAttribute("nextid");
element.setAction(client.getAppUri()); element.setAction(client.getAppUri());
submitButton.setText(uidl.getStringAttribute("buttoncaption")); submitButton.setText(uidl.getStringAttribute("buttoncaption"));
fu.setName(paintableId + "_file"); fu.setName(paintableId + "_file");
.getConsole() .getConsole()
.log( .log(
"Visiting server to see if upload started event changed UI."); "Visiting server to see if upload started event changed UI.");
client.sendPendingVariableChanges();
client.updateVariable(paintableId, "pollForStart",
nextUploadId, true);
} }
}; };
t.schedule(800); t.schedule(800);

+ 20
- 3
src/com/vaadin/ui/Upload.java View File



private boolean interrupted = false; private boolean interrupted = false;


private boolean notStarted;

private int nextid;

/* TODO: Add a default constructor, receive to temp file. */ /* TODO: Add a default constructor, receive to temp file. */


/** /**
*/ */
@Override @Override
public void changeVariables(Object source, Map variables) { public void changeVariables(Object source, Map variables) {
// NOP

if (variables.containsKey("pollForStart")) {
int id = (Integer) variables.get("pollForStart");
if (!isUploading && id == nextid) {
notStarted = true;
requestRepaint();
} else {
}
}
} }


/** /**
*/ */
@Override @Override
public void paintContent(PaintTarget target) throws PaintException { public void paintContent(PaintTarget target) throws PaintException {
if (notStarted) {
target.addAttribute("notStarted", true);
notStarted = false;
return;
}
// The field should be focused // The field should be focused
if (focus) { if (focus) {
target.addAttribute("focus", true); target.addAttribute("focus", true);


target.addAttribute("buttoncaption", buttonCaption); target.addAttribute("buttoncaption", buttonCaption);


target.addUploadStreamVariable(this, "stream");
target.addAttribute("nextid", nextid);

} }


/** /**
throw new IllegalStateException("uploading already started"); throw new IllegalStateException("uploading already started");
} }
isUploading = true; isUploading = true;
nextid++;
} }


/** /**

Loading…
Cancel
Save