如何在 GWT 或 GXT 中使用单个按钮发送同步发布请求?

发布于 2024-12-18 21:14:22 字数 229 浏览 3 评论 0原文

如何使用单个按钮发送 POST 请求而不创建任何附加的 FormPanel?

我想通过 POST 发送整个 HashMap 数据以填充报告,然后将此报告作为 XLS 文件流返回,因此用户应该看到“另存为...”对话框。

我无法通过 RequestBuilder 执行此操作,因为它会创建 AJAX 请求,并且无法以这种方式下载文件。

也许 Sencha 的 GXT 有解决方案?它也可以适合这里。

How can I send POST request with single button and without creating any FormPanel attached to it?

I want to send whole HashMap of data via POST for filling report and then return this report as XLS file stream, so the user should get "Save as..." dialog.

I can't do it by RequestBuilder as it creates AJAX requests and file can't be downloaded this way.

Maybe Sencha's GXT has a solution for this? It can fit here as well.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜尕妞 2024-12-25 21:14:22

这就是我所做的。发送 AJAX POST。然后,您的服务器应发送 XLS 的 URL 作为响应。当客户端(浏览器/GWT)收到响应时,它会打开一个带有 XLS url 的隐藏 IFRAME。如果服务器将“Content-Disposition”标头设置为“Attachment”,则会出现“另存为”对话框。

Here's what I've done. Send an AJAX POST. Your server should then send the URL of the XLS as a response. When the client (browser/GWT) receives the response, it opens up a hidden IFRAME with the XLS url. If the server sets the 'Content-Disposition' header to 'Attachment', the 'Save As' dialog will appear.

难以启齿的温柔 2024-12-25 21:14:22

您可以创建new FormPanel("_self")。此表单将直接返回您的 XLS 流,而不是返回到后台 iFrame。

You can create new FormPanel("_self"). This form will return your XLS stream directly, not to the background iFrame.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文