📄 frametag.java
字号:
/*
* FrameTag.java
*
* Created on 2002/01/29, 11:39
*/
package jp.co.intra_mart.framework.base.web.tag;
import java.util.Collection;
import java.util.Vector;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import jp.co.intra_mart.framework.base.service.ServiceManager;
import jp.co.intra_mart.framework.base.service.ServicePropertyHandler;
import jp.co.intra_mart.framework.base.service.ServiceSecurityFilter;
import jp.co.intra_mart.framework.base.service.ServiceServlet;
import jp.co.intra_mart.framework.base.session.SessionFactory;
import jp.co.intra_mart.framework.base.session.SessionManager;
import jp.co.intra_mart.framework.base.session.SessionPropertyException;
import jp.co.intra_mart.framework.base.session.SessionPropertyHandler;
import jp.co.intra_mart.framework.base.web.tag.attribute.CoreAttributes;
import jp.co.intra_mart.framework.util.SecurityUtil;
/**
* FRAME僞僌偱偡丅
* intra-mart僼儗乕儉儚乕僋傪巊梡偡傞応崌偺僙僢僔儑儞僼儗乕儉儚乕僋丄僒乕價僗僼儗乕儉儚乕僋偺堦晹偲側傝傑偡丅
*
* @author INTRAMART
* @version 1.0
*/
public class FrameTag extends BodyTagSupport implements ParameterSendable {
/**
* 僙僢僔儑儞儅僱乕僕儍
*/
private SessionManager sessionManager;
/**
* 僙僢僔儑儞僾儘僷僥傿僴儞僪儔
*/
private SessionPropertyHandler sessionHandler;
/**
* 僒乕價僗儅僱乕僕儍
*/
private ServiceManager serviceManager;
/**
* 僒乕價僗僾儘僷僥傿僴儞僪儔
*/
private ServicePropertyHandler serviceHandler;
/**
* 僐傾懏惈
*/
private CoreAttributes coreAttrs;
/**
* 僷儔儊乕僞偺廤崌
*/
private Collection params;
/**
* 傾僾儕働乕僔儑儞
*/
private String application;
/**
* 僒乕價僗
*/
private String service;
/**
* longdesc
*/
private String longdesc;
/**
* name
*/
private String name;
/**
* frameborder
*/
private String frameborder;
/**
* marginwidth
*/
private String marginwidth;
/**
* marginheight
*/
private String marginheight;
/**
* noresize
*/
private String noresize;
/**
* scrolling
*/
private String scrolling;
/**
* FrameTag傪怴婯偵惗惉偟傑偡丅
*/
public FrameTag() {
super();
try {
this.sessionManager = SessionManager.getSessionManager();
this.sessionHandler =
this.sessionManager.getSessionPropertyHandler();
this.serviceManager = ServiceManager.getServiceManager();
this.serviceHandler =
this.serviceManager.getServicePropertyHandler();
} catch (Exception e) {
throw new RuntimeException(e);
}
this.params = null;
this.coreAttrs = new CoreAttributes();
}
/**
* 奐巒僞僌傪専抦偟偨偲偒偵JSP僄儞僕儞偐傜屇偽傟傑偡丅
* FRAME僞僌傪夝庍偟傑偡丅
*
* @return EVAL_BODY_BUFFERED
* @throws JspException 僞僌偺夝庍帪偵椺奜偑敪惗
*/
public int doStartTag() throws JspException {
this.params = new Vector();
return EVAL_BODY_BUFFERED;
}
/**
* 廔椆僞僌傪専抦偟偨偲偒偵JSP僄儞僕儞偐傜屇偽傟傑偡丅
* FRAME僞僌傪廔椆偟傑偡丅
*
* @return EVAL_PAGE
* @throws JspException 僞僌偺廔椆帪偵椺奜偑敪惗
*/
public int doEndTag() throws JspException {
String contextPath = null;
String url = null;
Vector srcParams = null;
FrameworkTagParam param = null;
SessionFactory factory = null;
HttpSession httpSession = null;
String applicationID = null;
String serviceID = null;
String strCode = null;
String securityExt = null;
String tempPath = null;
String errorPage = null;
try {
TagWriter writer = new TagWriter(pageContext.getOut());
// Version 3.2 屳姺梡
contextPath = this.serviceHandler.getContextPath();
if (contextPath == null) {
contextPath =
((HttpServletRequest)pageContext.getRequest())
.getContextPath();
}
tempPath = contextPath
+ "/"
+ getApplication()
+ ServiceServlet.REQUEST_SEPARATOR
+ getService()
+ "."
+ serviceManager.getExtesion();
// 僷儔儊乕僞
srcParams = new Vector();
if (this.params != null) {
srcParams.addAll(this.params);
}
// 儕僋僄僗僩偲儗僗億儞僗偺庢摼
HttpServletRequest request =
(HttpServletRequest)pageContext.getRequest();
HttpServletResponse response =
(HttpServletResponse)pageContext.getResponse();
// 儕僋僄僗僩偺懏惈抣傪庢摼偡傞乮ServiceSecurityFilter僼儔僌乯
securityExt =
(String)request.getAttribute(
ServiceSecurityFilter.ID_SERVICE_SECURITY_FILTER);
// 僄儞僐乕僨傿儞僌偺庢摼
String encoding =
this.serviceManager.getEncoding(request, response);
// 僙僉儏儕僥傿偑桳岠偺偲偒
if (securityExt != null) {
// 僙僢僔儑儞庢摼
httpSession = request.getSession(false);
if (httpSession == null) {
try {
errorPage =
this.sessionHandler.getSessionErrorPagePath();
} catch (SessionPropertyException e) {
throw new ServletException(e.getMessage(), e);
}
request.getRequestDispatcher(errorPage).forward(
request,
response);
return SKIP_BODY;
}
// 傾僾儕働乕僔儑儞ID庢摼
applicationID = getApplication();
if (applicationID == null) {
applicationID = "";
}
// 僒乕價僗ID偺庢摼
serviceID = getService();
if (serviceID == null) {
serviceID = "";
}
// 傾僾儕働乕僔儑儞DI,僒乕價僗ID丄僙僢僔儑儞偵傛傝埫崋傪嶌惉
strCode =
SecurityUtil.createCheckSum(
applicationID,
serviceID,
httpSession);
tempPath = contextPath + "/" + strCode + "." + securityExt;
}
// 僙僢僔儑儞傪娷傔偨URL偺庢摼
factory = this.sessionManager.getSessionFactory();
if (factory == null) {
url =
((HttpServletResponse)pageContext.getResponse()).encodeURL(
TagWriter.createURL(tempPath, srcParams, encoding));
} else {
// Version 3.2 屳姺梡
if (factory.isEncodeRequired()) {
url =
factory.encodeURL(
pageContext.getRequest(),
pageContext.getResponse(),
TagWriter.createURL(tempPath, srcParams, encoding));
} else {
param = new FrameworkTagParam();
param.setName(this.sessionHandler.getSessionParameter());
param.setValue(
this
.sessionManager
.getSessionObject(pageContext.getRequest())
.getSessionID());
srcParams.add(param);
url =
TagWriter.createURL(
contextPath + this.serviceHandler.getServiceServletPath(),
srcParams,
encoding);
}
}
// FRAME僞僌奐巒
pageContext.getOut().print("<FRAME src=\"" + url + "\"");
// longdesc
writer.printAttribute("longdesc", getLongdesc());
// name
writer.printAttribute("name", getName());
// frameborder
writer.printAttribute("frameborder", getFrameborder());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -