01: package org.gridsphere.provider.portletui.tags;
02:
03: import org.gridsphere.provider.portletui.beans.MessageBoxBean;
04:
05: import javax.servlet.jsp.JspException;
06: import javax.servlet.jsp.JspWriter;
07:
08: /*
09: * @author <a href="mailto:oliver.wehrens@aei.mpg.de">Oliver Wehrens</a>
10: * @version $Id: MessageBoxTag.java 6385 2007-10-25 14:02:26Z wehrens $
11: */
12:
13: public class MessageBoxTag extends BaseComponentTag {
14:
15: protected MessageBoxBean messageBoxBean = null;
16: protected String style = null;
17:
18: /**
19: * Sets the style of the text: Available styles are
20: * <ul>
21: * <li>nostyle</li>
22: * <li>error</li>
23: * <li>info</li>
24: * <li>status</li>
25: * <li>alert</li>
26: * <li>success</li>
27: *
28: * @param style the text style
29: */
30: public void setStyle(String style) {
31: this .style = style;
32: }
33:
34: /**
35: * Returns the style of the text: Available styles are
36: * <ul>
37: * <li>nostyle</li>
38: * <li>error</li>
39: * <li>info</li>
40: * <li>status</li>
41: * <li>alert</li>
42: * <li>success</li>
43: * <li>bold</li>
44: * <li>italic</li>
45: * <li>underline</li>
46: *
47: * @return the text style
48: */
49: public String getStyle() {
50: return style;
51: }
52:
53: public int doStartTag() throws JspException {
54: return EVAL_BODY_INCLUDE;
55: }
56:
57: public int doEndTag() throws JspException {
58: if (!beanId.equals("")) {
59: messageBoxBean = (MessageBoxBean) getTagBean();
60: if (messageBoxBean == null) {
61: messageBoxBean = new MessageBoxBean();
62: this .setBaseComponentBean(messageBoxBean);
63: } else {
64: this .updateBaseComponentBean(messageBoxBean);
65: key = messageBoxBean.getKey();
66: }
67: } else {
68: messageBoxBean = new MessageBoxBean();
69: this .setBaseComponentBean(messageBoxBean);
70: }
71: if (style != null) {
72: messageBoxBean.setMessageType(style);
73: }
74: if (key != null) {
75: messageBoxBean.setValue(getLocalizedText(key));
76: }
77:
78: try {
79: JspWriter out = pageContext.getOut();
80: out.print(messageBoxBean.toEndString());
81: } catch (Exception e) {
82: throw new JspException(e.getMessage());
83: }
84:
85: return EVAL_PAGE;
86: }
87:
88: }
|