01: /*
02: * Copyright 2002 Sun Microsystems, Inc. All
03: * rights reserved. Use of this product is subject
04: * to license terms. Federal Acquisitions:
05: * Commercial Software -- Government Users
06: * Subject to Standard License Terms and
07: * Conditions.
08: *
09: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
10: * are trademarks or registered trademarks of Sun Microsystems,
11: * Inc. in the United States and other countries.
12: */
13:
14: package com.sun.portal.portlet.taglib;
15:
16: import java.io.IOException;
17:
18: import javax.servlet.jsp.PageContext;
19: import javax.servlet.jsp.JspException;
20: import javax.servlet.jsp.JspTagException;
21: import javax.servlet.jsp.tagext.TagSupport;
22: import javax.servlet.http.HttpServletRequest;
23:
24: import javax.portlet.RenderResponse;
25:
26: /**
27: * This class implements the Namespace tag. It generates a string value in the portlet
28: * namespace and therefore ensures the uniqueness of the string value in the whole
29: * portal page.
30: */
31: public class NamespaceTag extends TagSupport {
32:
33: public int doStartTag() throws JspException {
34:
35: HttpServletRequest req = (HttpServletRequest) pageContext
36: .getRequest();
37:
38: RenderResponse rRes = (RenderResponse) req
39: .getAttribute(PortletTaglibConstants.RENDER_RESPONSE_ATTRIBUTE);
40:
41: try {
42: pageContext.getOut().print(rRes.getNamespace());
43: } catch (IOException e) {
44: throw new JspTagException(
45: "Error: IOException while writing");
46: }
47: return SKIP_BODY;
48: }
49: }
|