---
title: "Ext.Window"
author: "thw"
date: "2011-01-20T16:46:07Z"
tags: ["C#", "CSS", "EXT", "JSP", "JavaScript"]
categories: ["Web前端"]
slug: "ext-window"
draft: false
lastmod: "2011-01-20T16:46:07Z"
id: 890041
url: "https://thw.iteye.com/blog/890041"
---

Ext.Window  
1 在一个Ext web应用中，在每一个用到Ext的程序页面中都必须引入ext的js和css等文件，因此我们定义了一个include.jsp文件，此文件的内容大致为：  
jsp代码：

&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;  
&lt;%@ page session="true"%&gt;  
&lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%&gt;  
&lt;%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%&gt;     
&lt;%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %&gt;    
&lt;%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %&gt;  
&lt;%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %&gt;  
&lt;%@page import="org.apache.commons.logging.Log,org.apache.commons.logging.LogFactory"%&gt;   
&lt;anyxmlelement xmlns:fn="http://java.sun.com/jsp/jstl/functions" /&gt;  
&lt;%  
        request.setAttribute("path", request.getContextPath());  
    application.setAttribute("parameter",ParameterFactory.getColMap());  
%&gt;  
&lt;Script Language="javaScript" src="${path}/commons/commons.js"&gt;&lt;/Script&gt;  
&lt;link rel="stylesheet" type="text/css" media="all" href="&lt;c:out value="${path}" /&gt;/jsLibs/extJS/resources/css/ext-all.css" /&gt;  
&lt;link rel="stylesheet" type="text/css" media="all" href="&lt;c:out value="${path}" /&gt;/jsLibs/extJS/resources/css/xtheme-gray.css" /&gt;  
&lt;link rel="stylesheet" type="text/css" media="all" href="&lt;c:out value="${path}" /&gt;/jsLibs/extJS/resources/css/fileuploadfield.css" /&gt;  
&lt;script type="text/javascript" src="&lt;c:out value="${path}" /&gt;/jsLibs/extJS/adapter/ext/ext-base.js"&gt;&lt;/script&gt;    
&lt;script type="text/javascript" src="&lt;c:out value="${path}" /&gt;/jsLibs/extJS/ext-all.js"&gt;&lt;/script&gt;    
&lt;script type="text/javascript" src="&lt;c:out value="${path}" /&gt;/jsLibs/extJS/ext-lang-zh\_CN.js"&gt;&lt;/script&gt;  
&lt;script type="text/javascript" src="&lt;c:out value="${path}" /&gt;/jsLibs/extJS/ux/FileUploadField.js"&gt;&lt;/script&gt;  
&lt;LINK href="${path}/commons/style.css" type="text/css" rel=stylesheet&gt;  
   
&lt;Script LANGUAGE="JavaScript"&gt;  
       
       Ext.BLANK\_IMAGE\_URL = "&lt;c:out value="${path}" /&gt;/jsLibs/extJS/resources/images/default/s.gif";  
    /\**  
    \*创建Ext.Window时,设置创建事件所在的window对象  
    \*/  
    Ext.Window.prototype.setCreateWin=function(win){  
        this.createWin=win;  
    }  
    Ext.Window.prototype.getCreateWin=function(){  
        return this.createWin;  
    }

    //取最上層EXT  
    function getTopExt(){  
        var topExt;  
        try{  
            topExt=top.Ext;  
        }catch(ex){  
            topExt=Ext;  
        }  
        return topExt;  
    }  
     
&lt;/Script&gt;

在每个具体的jsp页面，我们可以将此 include.jsp文件保护进来：  
&lt;%@ include  file="/WEB-INF/view/include/include.jsp"%&gt;

2 Ext.Window:  
将此window创建在顶层页面作用域中。  
var parExt = getTopExt();  
var addWin = new parExt.Window({  
        id: 'marcInfoWin',  
    title: "物料新增",  
    width: 1000,  
    height: 600,  
    resizable: true,  
    maximizable: true,  
    modal: true,  
    html: '&lt;iframe style="width:100%;height:100%;" frameborder="0" '+  
        'src="&lt;c:out value="${path}"/&gt;/marcInfo.htm?method=turnToModifyMarcInfoView&flag=add"&gt;&lt;/iframe&gt;'  
    });  
//将当前window设置为创建拖动窗口的window  
addWin.setCreateWin(window);  
addWin.show();

//取得创建的拖动窗口  
var marcInfoWin = parExt.ComponentMgr.get('marcInfoWin');  
//取得创建 拖动窗口的 window  
var domWin = marcInfoWin.getCreateWin();  
domWin.indexFun.callBack(marcInfObj);