001: package org.gridsphere.provider.portletui.tags;
002:
003: import org.gridsphere.portlet.impl.SportletProperties;
004: import org.gridsphere.provider.portletui.beans.DialogBean;
005:
006: import javax.portlet.RenderResponse;
007: import javax.servlet.jsp.JspException;
008: import javax.servlet.jsp.JspWriter;
009: import javax.servlet.jsp.PageContext;
010:
011: /**
012: * The <code>DialogTag</code> is a wrapper for the
013: * <a href="http://developer.yahoo.com/yui/container/panel/">Yahoo UI Panel</a> javascript widget
014: */
015: public class DialogTag extends BaseComponentTag {
016:
017: protected String body = "";
018: protected String titleColor = null;
019: protected String header = "";
020: protected String footer = "";
021: protected String width = "";
022: protected String height = "";
023: protected Boolean isModal = false;
024: protected Boolean isClose = true;
025: protected Boolean isDraggable = true;
026: protected Boolean isResizable = false;
027: protected String onClick = null;
028: protected Boolean isLink = false;
029:
030: public String getWidth() {
031: return width;
032: }
033:
034: public void setWidth(String width) {
035: this .width = width;
036: }
037:
038: public String getHeight() {
039: return height;
040: }
041:
042: public void setHeight(String height) {
043: this .height = height;
044: }
045:
046: public Boolean getModal() {
047: return isModal;
048: }
049:
050: public void setModal(Boolean modal) {
051: isModal = modal;
052: }
053:
054: public Boolean getClose() {
055: return isClose;
056: }
057:
058: public void setClose(Boolean close) {
059: isClose = close;
060: }
061:
062: public Boolean getResizable() {
063: return isResizable;
064: }
065:
066: public void setResizable(Boolean resizable) {
067: isResizable = resizable;
068: }
069:
070: public Boolean getDraggable() {
071: return isDraggable;
072: }
073:
074: public void setDraggable(Boolean draggable) {
075: isDraggable = draggable;
076: }
077:
078: public String getTitleColor() {
079: return titleColor;
080: }
081:
082: public void setTitleColor(String titleColor) {
083: this .titleColor = titleColor;
084: }
085:
086: public String getBody() {
087: return body;
088: }
089:
090: public void setBody(String body) {
091: this .body = body;
092: }
093:
094: public String getHeader() {
095: return header;
096: }
097:
098: public void setHeader(String header) {
099: this .header = header;
100: }
101:
102: public String getFooter() {
103: return footer;
104: }
105:
106: public void setFooter(String footer) {
107: this .footer = footer;
108: }
109:
110: public void release() {
111: super .release();
112: body = "";
113: titleColor = null;
114: header = "";
115: footer = "";
116: width = "";
117: height = "";
118: isModal = false;
119: isClose = true;
120: isDraggable = true;
121: isResizable = false;
122: onClick = null;
123: isLink = false;
124: }
125:
126: protected void setProperties(DialogBean dialog) {
127: if (key != null)
128: value = getLocalizedText(key);
129: RenderResponse res = (RenderResponse) pageContext.getAttribute(
130: SportletProperties.RENDER_RESPONSE,
131: PageContext.REQUEST_SCOPE);
132: dialog.setRenderResponse(res);
133: dialog.setId(id);
134: dialog.setWidth(width);
135: dialog.setHeight(height);
136: dialog.setHeader(header);
137: dialog.setBody(body);
138: dialog.setOnClick(onClick);
139: dialog.setFooter(footer);
140: dialog.setClose(isClose);
141: dialog.setModal(isModal);
142: dialog.setDraggable(isDraggable);
143: dialog.setResizable(isResizable);
144: dialog.setTitleColor(titleColor);
145: dialog.setLink(isLink);
146: dialog.setValue(value);
147: dialog.setName(name);
148: }
149:
150: public int doStartTag() throws JspException {
151:
152: DialogBean dialog = new DialogBean();
153: onClick = "YAHOO." + id + ".panel.show();";
154: setProperties(dialog);
155:
156: JspWriter out;
157: try {
158: out = pageContext.getOut();
159: out.print(dialog.toStartString());
160: } catch (Exception e) {
161: throw new JspException(e);
162: }
163: return SKIP_BODY;
164: }
165:
166: public int doEndTag() throws JspException {
167: release();
168: return EVAL_PAGE;
169: }
170: }
|