代码之家  ›  专栏  ›  技术社区  ›  Hasan

Ext JS中的另存为对话框

  •  0
  • Hasan  · 技术社区  · 7 年前


    我想问一下 另存为 “ExtJS Modern中的对话?所以我可以将网页中的对象保存到本地文件中。

    2 回复  |  直到 7 年前
        1
  •  0
  •   Hasan    7 年前

    一个解决方案(取决于Web浏览器,并非所有浏览器都支持!)正在使用Mozilla API(文件和blob),如: https://developer.mozilla.org/en-US/docs/Web/API/File/File https://developer.mozilla.org/en-US/docs/Web/API/Blob

        2
  •  0
  •   Hasan    7 年前

    另一个解决方案取决于portlet概念:

    1. 在ViewController中,您触发一个事件,例如“下载文件”
    2. 在主控制器中,捕捉事件并执行函数“downloadfile”,然后调用一个同名的函数。
    3. AjaxController(ext.app.controller)您调用函数doStandardSubmit

      location.href=this.url+'&operation=download&param1='+param1val;

    4. 在portlet(Java)的后端,您编写端点方法:

      @EndpointMethod(编码=假) 公共void下载(dataaccessor dataaccessor,authenticationGenerationConfiguration配置, @requestkey string param1,resourceresponse response)引发IOException{

      outputstream outputstream=response.getportletoutputstream(); 尝试{

                  // Adjusting content type
                  response.setContentType("text/plain");
                  response.setProperty("Content-Disposition", "attachment; filename=\"" + FILENAME + "\"");
                      outputStream.flush();
              } finally {
                  outputStream.close();
              }
          }
      
    推荐文章