01: /**
02: * $Id: AttrTag.java,v 1.7 2005/09/21 10:53:03 dg154973 Exp $
03: * Copyright 2002 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.wireless.taglibs.util;
14:
15: import javax.servlet.jsp.*;
16: import javax.servlet.jsp.tagext.*;
17: import java.io.*;
18: import java.util.logging.Level;
19: import java.util.logging.LogRecord;
20: import java.util.logging.Logger;
21:
22: import javax.servlet.*;
23: import javax.servlet.http.*;
24:
25: import com.sun.portal.log.common.PortalLogger;
26: import com.sun.portal.wireless.taglibs.base.*;
27:
28: /**
29: * <util:attr> tag implementation.
30: *
31: *
32: * @author John Saare
33: * @version 1.0, 03/08/2001
34: */
35: public class AttrTag extends BaseBodyTagSupport {
36:
37: private String attrName = null;
38:
39: private static Logger logger = PortalLogger
40: .getLogger(AttrTag.class);
41:
42: /**
43: * Called at the beginning of a tag...
44: *
45: * @return what to do next
46: */
47: public int doStartTag() throws JspTagException {
48: return (EVAL_BODY_TAG);
49: }
50:
51: /**
52: * Called after the tag body has been processed...
53: *
54: * @return what to do next
55: */
56: public int doAfterBody() throws JspException {
57: BodyContent body = getBodyContent();
58: try {
59: JspWriter out = body.getEnclosingWriter();
60: out.print(" " + attrName + "=\"" + body.getString() + "\"");
61: body.clearBody();
62: } catch (Exception e) {
63: if (logger.isLoggable(Level.SEVERE)) {
64: LogRecord rec = new LogRecord(Level.SEVERE,
65: "PSMA_CSPWTU0002");
66: rec.setThrown(e);
67: String[] param = { "out.print()" };
68: rec.setParameters(param);
69: rec.setLoggerName(logger.getName());
70: logger.log(rec);
71: }
72: throw new JspException(this .getClass().getName()
73: + ".doAfterBody() failed. out.print() failed.");
74: }
75: return (SKIP_BODY);
76: }
77:
78: /**
79: * "attr" attribute set method...
80: *
81: * @param s attribute value.
82: */
83: public void setAttr(String s) {
84: attrName = Util.evalAttribute(pageContext, s);
85: }
86:
87: }
|