我将xmls列表的内容作为字符串,我需要将其传递给隐藏变量中的服务器。我将fileName作为键转换为map,将值转换为字符串,转换为json以将其传递给服务器。但是当我将它设置为隐藏变量时,它不起作用。如果我删除这个隐藏的变量,一切正常。我不能使用fileUpload,因为我将字符串中的内容作为调用的输出。我不想将文件保存在服务器中,然后下载它。请指教。
public void sendFiletoDownload(Map<String, String> result) {
String jsonResult = JSONUIHelper.toJson(result);
FormPanel form = new FormPanel();
_log.logMsg(BsLogLvl.DEBUG, "form.start;"+GWT.getModuleBaseURL());
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);
form.setAction(GWT.getModuleBaseURL() + "dnldSvc");
_log.logMsg(BsLogLvl.DEBUG, "form.submit();"+StringUtil.makeXMLSafe(jsonResult));
Hidden hiddenFileName = new Hidden("fileName", "PltAtty.zip");
Hidden hiddenJSON = new Hidden("jsonData", StringUtil.makeXMLSafe(jsonResult));
//SafeHTMLUtils.
form.add(hiddenFileName);
form.add(hiddenJSON);
_log.logMsg(BsLogLvl.DEBUG, "form.submit();");
form.submit();
_log.logMsg(BsLogLvl.DEBUG, "after submit();");
form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
public void onSubmitComplete(SubmitCompleteEvent event) {
_log.logMsg(BsLogLvl.DEBUG, "after onSubmitComplete;"+event);
}
});
}