用windchill原生API在前台直接下载文件

页面用的是MVC组件开发,然后页面有定义一个下载按钮
用windchill原生API在前台直接下载文件_第1张图片
对应页面的后台jsp关键按钮和下载的代码如下:

*Part Number:
--这个就是导出的按钮
对应的js方法如下: function makeExcel() { var cover = document.getElementById('cover'); cover.style.display = 'block'; setTimeout(function() { cover.style.display = 'none'; var rootNumber = PTC.jca.table.Utils.getExtTables()[0].store.data.items[0].data.number.gui.comparable; rootNumber=rootNumber.substr(1,rootNumber.length); var tempUrl = '<%=baseUrl%>netmarkets/jsp/ext/tct/partlistsearch/export.jsp?targetFile='+rootNumber; PTC.util.downloadUrl(tempUrl); }, 5000); } 那最主要的一行代码就是:PTC.util.downloadUrl(tempUrl);

需要在action中配置下载的入口:
用windchill原生API在前台直接下载文件_第2张图片
下载jsp的内容:

<%@page language="java" session="true" pageEncoding="UTF-8"%>
<%@ page import="wt.httpgw.URLFactory"%>
<%@ page import="ext.tct.globalamlsearch.util.ExportUtil"%>
<%@ taglib prefix="jca"
	uri="http://www.ptc.com/windchill/taglib/components"%>
<%@ taglib prefix="jcamvc"
	uri="http://www.ptc.com/windchill/taglib/jcaMvc"%>
<%@ taglib uri="http://www.ptc.com/windchill/taglib/mvc" prefix="mvc"%>
<%@ taglib prefix="wrap"
	uri="http://www.ptc.com/windchill/taglib/wrappers"%>
<%@ taglib tagdir="/WEB-INF/tags" prefix="wctags"%>
<%@ include file="/netmarkets/jsp/util/begin.jspf"%>

downloading.....

It could take a small amount of time, please waiting!
<% URLFactory urlFactory = new URLFactory(); String baseUrl = urlFactory.getBaseURL().toExternalForm(); String targetFile = request.getParameter("targetFile");//用request得到 System.out.println("targetFile="+targetFile); ext.tct.partlistsearch.service.PartListSearchCommService.partListSearchDownload(response,targetFile); response.flushBuffer(); out.clear(); out = pageContext.pushBody(); %> <%@ include file="/netmarkets/jsp/util/end.jspf"%>

你可能感兴趣的:(Windchill)