01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.jsp.tag.presentation;
16:
17: import java.io.IOException;
18: import java.io.Writer;
19: import javax.servlet.jsp.JspException;
20: import org.araneaframework.jsp.util.JspUtil;
21:
22: /**
23: * Standard image base tag.
24: *
25: * @author Oleg Mürk
26: */
27: public abstract class BaseImageHtmlTag extends BaseImageTag {
28: {
29: baseStyleClass = "aranea-image";
30: }
31:
32: protected int doStartTag(Writer out) throws Exception {
33: super .doStartTag(out);
34: writeImageLocal(out, src, width, height, alt, getStyleClass(),
35: title);
36: return EVAL_BODY_INCLUDE;
37: }
38:
39: /**
40: * Method to write out image with given properties and default style.
41: */
42: public void writeImage(Writer out, String src, String width,
43: String height, String title) throws JspException,
44: IOException {
45: writeImage(out, src, width, height, null, getStyleClass(),
46: title);
47: }
48:
49: public void writeImageLocal(Writer out, String src, String width,
50: String height, String alt, String styleClass, String title)
51: throws JspException, IOException {
52: writeImage(out, src, width, height, alt, styleClass, title);
53: }
54:
55: /* ***********************************************************************************
56: * STATIC methods for writing out <IMG> tag
57: * ***********************************************************************************/
58: /**
59: * Static method to write out image with given properties.
60: */
61: public static void writeImage(Writer out, String src, String width,
62: String height, String styleClass, String title)
63: throws JspException, IOException {
64: writeImage(out, src, width, height, null, styleClass, title);
65: }
66:
67: /**
68: * Static method to write out image with given properties.
69: */
70: public static void writeImage(Writer out, String src, String width,
71: String height, String alt, String styleClass, String title)
72: throws JspException, IOException {
73: JspUtil.writeOpenStartTag(out, "img");
74: if (styleClass != null)
75: JspUtil.writeAttribute(out, "class", styleClass);
76:
77: JspUtil.writeAttribute(out, "src", src, false);
78: JspUtil.writeAttribute(out, "width", width);
79: JspUtil.writeAttribute(out, "height", height);
80: JspUtil.writeAttribute(out, "border", 0 + "");
81: JspUtil.writeAttribute(out, "alt", alt);
82: JspUtil.writeAttribute(out, "title", title);
83:
84: JspUtil.writeCloseStartEndTag_SS(out);
85: }
86: }
|