001: /*
002: * @author <a href="mailto:novotny@gridsphere.org">Jason Novotny</a>
003: * @author <a href="mailto:oliver.wehrens@aei.mpg.de">Oliver Wehrens</a>
004: * @version $Id: ImageTag.java 6385 2007-10-25 14:02:26Z wehrens $
005: */
006: package org.gridsphere.provider.portletui.tags;
007:
008: import org.gridsphere.provider.portletui.beans.ImageBean;
009:
010: import javax.servlet.jsp.JspException;
011: import javax.servlet.jsp.JspWriter;
012: import javax.servlet.jsp.tagext.Tag;
013:
014: /**
015: * The <code>ImageTag</code> represents an href img element
016: */
017: public class ImageTag extends BaseComponentTag {
018:
019: protected ImageBean urlImageBean = null;
020: protected String src = null;
021: protected String border = null;
022: protected String title = null;
023: protected String alt = null;
024: protected String width = null;
025: protected String height = null;
026: protected String align = null;
027:
028: /**
029: * Returns the location of the image
030: *
031: * @return src the location of the image
032: */
033: public String getSrc() {
034: return src;
035: }
036:
037: /**
038: * Sets the location of the image
039: *
040: * @param src the location of the image
041: */
042: public void setSrc(String src) {
043: this .src = src;
044: }
045:
046: /**
047: * Return the image title border
048: *
049: * @return the image title border
050: */
051: public String getBorder() {
052: return border;
053: }
054:
055: /**
056: * Sets the image title border
057: *
058: * @param border the image title border
059: */
060: public void setBorder(String border) {
061: this .border = border;
062: }
063:
064: /**
065: * Return the image title
066: *
067: * @return the image title
068: */
069: public String getTitle() {
070: return title;
071: }
072:
073: /**
074: * Sets the image title
075: *
076: * @param title the image title
077: */
078: public void setTitle(String title) {
079: this .title = title;
080: }
081:
082: /**
083: * Return the associated alt attribute
084: *
085: * @return the alt tag
086: */
087: public String getAlt() {
088: return alt;
089: }
090:
091: /**
092: * Sets an alt tag to display
093: *
094: * @param alt the alt tag
095: */
096: public void setAlt(String alt) {
097: this .alt = alt;
098: }
099:
100: /**
101: * Sets the table alignment e.g. "left", "top", "bottom" or "right"
102: *
103: * @param align the table alignment
104: */
105: public void setAlign(String align) {
106: this .align = align;
107: }
108:
109: /**
110: * Returns the table alignment e.g. "left", "top", "bottom" or "right"
111: *
112: * @return the table alignment
113: */
114: public String getAlign() {
115: return align;
116: }
117:
118: /**
119: * Sets the table cell width
120: *
121: * @param width the table cell width
122: */
123: public void setWidth(String width) {
124: this .width = width;
125: }
126:
127: /**
128: * Returns the table cell width
129: *
130: * @return the table cell width
131: */
132: public String getWidth() {
133: return width;
134: }
135:
136: /**
137: * Sets the table cell height
138: *
139: * @param height the table cell height
140: */
141: public void setHeight(String height) {
142: this .height = height;
143: }
144:
145: /**
146: * Returns the table cell height
147: *
148: * @return the table cell height
149: */
150: public String getHeight() {
151: return height;
152: }
153:
154: private void setImageBean(ImageBean urlImageBean) {
155: this .setBaseComponentBean(urlImageBean);
156: if (alt != null)
157: urlImageBean.setAlt(alt);
158: if (title != null)
159: urlImageBean.setTitle(title);
160: if (src != null)
161: urlImageBean.setSrc(src);
162: if (border != null)
163: urlImageBean.setBorder(border);
164: if (width != null)
165: urlImageBean.setWidth(width);
166: if (height != null)
167: urlImageBean.setHeight(height);
168: if (align != null)
169: urlImageBean.setAlign(align);
170: }
171:
172: public int doStartTag() throws JspException {
173: if (!beanId.equals("")) {
174: urlImageBean = (ImageBean) getTagBean();
175: if (urlImageBean == null) {
176: urlImageBean = new ImageBean();
177: }
178: } else {
179: urlImageBean = new ImageBean();
180: }
181: setImageBean(urlImageBean);
182:
183: Tag parent = getParent();
184: if (parent instanceof ActionLinkTag) {
185: ActionLinkTag actionTag = (ActionLinkTag) parent;
186: actionTag.setImageBean(urlImageBean);
187: } else {
188: try {
189: JspWriter out = pageContext.getOut();
190: out.print(urlImageBean.toStartString());
191: } catch (Exception e) {
192: throw new JspException(e.getMessage());
193: }
194: }
195: return SKIP_BODY;
196: }
197:
198: }
|