01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.desktop.taglib.providerContext;
06:
07: import java.util.Map;
08:
09: import javax.servlet.jsp.JspException;
10: import javax.servlet.http.HttpServletRequest;
11:
12: import com.sun.portal.desktop.taglib.BaseDesktopTagSupport;
13: import com.sun.portal.providers.Provider;
14: import com.sun.portal.providers.ProviderAdapter;
15: import com.sun.portal.providers.context.ProviderContext;
16: import com.sun.portal.desktop.context.ContextException;
17: import com.sun.portal.desktop.taglib.DesktopTaglibException;
18:
19: public class GetDesktopURLTag extends BaseProviderContextTagSupport {
20: private String m_querymap = null;
21: private String m_querystring = null;
22: private String m_pathinfo = null;
23: private boolean m_escape = false;
24:
25: public void setQuerymap(String querymap)
26: throws DesktopTaglibException {
27: m_querymap = querymap;
28: }
29:
30: public void setQuerystring(String querystring)
31: throws DesktopTaglibException {
32: m_querystring = querystring;
33: }
34:
35: public void setPathinfo(String pathinfo)
36: throws DesktopTaglibException {
37: m_pathinfo = pathinfo;
38: }
39:
40: public void setEscape(String escape) throws DesktopTaglibException {
41: m_escape = toBoolean(escape);
42: }
43:
44: public int doStartTag() throws JspException {
45: if (m_querymap != null && m_querystring != null) {
46: throw new DesktopTaglibException(
47: DesktopTaglibException.INVALID_PARAMETER,
48: "queryMap attribute and queryString attribute cannot coexist");
49: }
50: ProviderContext pc = getCurrentProviderContext();
51: String result = null;
52: if (m_querystring != null) {
53: String queryString = (String) resolveParameter(m_querystring);
54: result = pc.getDesktopURL((HttpServletRequest) pageContext
55: .getRequest(), queryString, m_escape);
56: } else if (m_querymap != null || m_pathinfo != null) {
57: Map querymap = null;
58: Map pathinfo = null;
59: if (m_querymap != null) {
60: querymap = (Map) resolveParameter(m_querymap);
61: }
62: if (m_pathinfo != null) {
63: pathinfo = (Map) resolveParameter(m_pathinfo);
64: }
65: if (m_escape) {
66: result = pc.getDesktopURL(
67: (HttpServletRequest) pageContext.getRequest(),
68: querymap, pathinfo, m_escape);
69: } else {
70: result = pc.getDesktopURL(
71: (HttpServletRequest) pageContext.getRequest(),
72: querymap, pathinfo);
73: }
74: } else {
75: result = pc.getDesktopURL((HttpServletRequest) pageContext
76: .getRequest());
77: }
78: processResult(result);
79: return SKIP_BODY;
80: }
81: }
|