public void execute(CommandResponse r) {
stopProgress();
if (r instanceof PrintGetTemplateResponse) {
PrintGetTemplateResponse response = (PrintGetTemplateResponse) r;
GWT.log("Downloading " + response.getDocumentId(), null);
UrlBuilder url = new UrlBuilder(GWT.getHostPageBaseURL());
url.addPath("d/printing").addParameter("documentId", response.getDocumentId());
url.addParameter("name", (String) fileNameItem.getValue());
url.addParameter("userToken", command.getUserToken());
if ("save".equals(downloadTypeGroup.getValue())) {
url.addParameter("download", "1");
String encodedUrl = url.toString();
// create a hidden iframe to avoid popups ???
HTMLPanel hiddenFrame = new HTMLPanel("<iframe src='" + encodedUrl
+ "'+style='position:absolute;width:0;height:0;border:0'>");
hiddenFrame.setVisible(false);
addChild(hiddenFrame);
} else {
url.addParameter("download", "0");
String encodedUrl = url.toString();
com.google.gwt.user.client.Window.open(encodedUrl, "_blank", null);
}
}
}
});