Source Code Cross Referenced for Image.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » netui » tags » html » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache beehive 1.0.2 src » org.apache.beehive.netui.tags.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         *
017:         * $Header:$
018:         */
019:        package org.apache.beehive.netui.tags.html;
020:
021:        import org.apache.beehive.netui.tags.internal.PageFlowTagUtils;
022:        import org.apache.beehive.netui.tags.rendering.AbstractHtmlState;
023:        import org.apache.beehive.netui.tags.rendering.ImageTag;
024:        import org.apache.beehive.netui.tags.rendering.TagRenderingBase;
025:        import org.apache.beehive.netui.tags.rendering.WriteRenderAppender;
026:        import org.apache.beehive.netui.util.Bundle;
027:        import org.apache.beehive.netui.util.ParamHelper;
028:
029:        import javax.servlet.ServletRequest;
030:        import javax.servlet.http.HttpServletRequest;
031:        import javax.servlet.http.HttpServletResponse;
032:        import javax.servlet.jsp.JspException;
033:        import java.net.URISyntaxException;
034:        import java.util.HashMap;
035:        import java.util.Map;
036:
037:        /**
038:         * Generates an image with the specified attributes.  Image ignores its
039:         * body content.
040:         * @jsptagref.tagdescription Renders an HTML <img> tag with specified attributes.
041:         * @example In this sample, an Image shows "friends.jpg" at 150 x 175 pixels, with the id "Friends".
042:         * <pre>&lt;netui:image src="friends.jpg" tagId="Friends" height="150" width="175" /></pre>
043:         * @netui:tag name="image" description="Places an image file type on your page."
044:         */
045:        public class Image extends HtmlBaseTag implements  IUrlParams {
046:            private ImageTag.State _state = new ImageTag.State();
047:
048:            private String _location = null; // The location hash to append to the url.
049:            private Map _params;
050:
051:            /**
052:             * Return the name of the Tag.
053:             */
054:            public String getTagName() {
055:                return "Image";
056:            }
057:
058:            /**
059:             * This method will return the state associated with the tag.  This is used by this
060:             * base class to access the individual state objects created by the tags.
061:             * @return a subclass of the <code>AbstractHtmlState</code> class.
062:             */
063:            protected AbstractHtmlState getState() {
064:                return _state;
065:            }
066:
067:            /**
068:             * Base support for the attribute tag.  This is overridden to prevent setting the <code>src</code>
069:             * attribute.
070:             * @param name  The name of the attribute.  This value may not be null or the empty string.
071:             * @param value The value of the attribute.  This may contain an expression.
072:             * @param facet The name of a facet to which the attribute will be applied.  This is optional.
073:             * @throws JspException A JspException may be thrown if there is an error setting the attribute.
074:             */
075:            public void setAttribute(String name, String value, String facet)
076:                    throws JspException {
077:                if (name != null && name.equals(SRC)) {
078:                    String s = Bundle.getString("Tags_AttributeMayNotBeSet",
079:                            new Object[] { name });
080:                    registerTagError(s, null);
081:                }
082:                super .setAttribute(name, value, facet);
083:            }
084:
085:            /**
086:             * Sets the property to specify where to align the image.
087:             * @param align the image alignment.
088:             * @jsptagref.attributedescription The alignment of the image.
089:             * @jsptagref.databindable false
090:             * @jsptagref.attributesyntaxvalue <i>string_align</i>
091:             * @netui:attribute required="false" rtexprvalue="true"
092:             * description="The alignment of the image."
093:             */
094:            public void setAlign(String align) {
095:                _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ALIGN,
096:                        align);
097:            }
098:
099:            /**
100:             * Sets the property to specify the alt text of the image.
101:             * @param alt the image alignment.
102:             * @jsptagref.attributedescription The alternative text of the image
103:             * @jsptagref.databindable Read Only
104:             * @jsptagref.attributesyntaxvalue <i>string_alt</i>
105:             * @netui:attribute required="false" rtexprvalue="true"
106:             * description="The alternative text of the image."
107:             */
108:            public void setAlt(String alt) {
109:                _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ALT,
110:                        alt, true);
111:            }
112:
113:            /**
114:             * Sets the property to specify a link to the the long description to supplement
115:             * the short description in the <code>alt</code> attribute.
116:             * @param longdesc the longdesc.
117:             * @jsptagref.attributedescription Specifies a link to the the long description.
118:             * @jsptagref.databindable false
119:             * @jsptagref.attributesyntaxvalue <i>string_longdesc</i>
120:             * @netui:attribute required="false" rtexprvalue="true"
121:             * description="Specifies a link to the the long description."
122:             */
123:            public void setLongdesc(String longdesc) {
124:                _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
125:                        LONGDESC, longdesc);
126:            }
127:
128:            /**
129:             * Sets the border size around the image.
130:             * @param border the border size.
131:             * @jsptagref.attributedescription The border size around the image
132:             * @jsptagref.databindable false
133:             * @jsptagref.attributesyntaxvalue <i>integer_pixelBorder</i>
134:             * @netui:attribute required="false"  rtexprvalue="true"
135:             * description="The border size around the image."
136:             */
137:            public void setBorder(String border) {
138:                _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
139:                        BORDER, border);
140:            }
141:
142:            /**
143:             * Sets the image height.
144:             * @param height the height.
145:             * @jsptagref.attributedescription The image height
146:             * @jsptagref.databindable Read Only
147:             * @jsptagref.attributesyntaxvalue <i>integer_height</i>
148:             * @netui:attribute required="false"  rtexprvalue="true"
149:             * description="The image height."
150:             */
151:            public void setHeight(String height) {
152:                _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
153:                        HEIGHT, height);
154:            }
155:
156:            /**
157:             * Sets the the horizontal spacing around the image.
158:             * @param hspace the horizontal spacing.
159:             * @jsptagref.attributedescription The horizontal spacing around the image.
160:             * @jsptagref.databindable Read Only
161:             * @jsptagref.attributesyntaxvalue <i>integer_hspace</i>
162:             * @netui:attribute required="false" rtexprvalue="true"
163:             * description="The horizontal spacing around the image."
164:             */
165:            public void setHspace(String hspace) {
166:                _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
167:                        HSPACE, hspace);
168:            }
169:
170:            /**
171:             * Sets the server-side image map declaration.
172:             * @param ismap the image map declaration.
173:             * @jsptagref.attributedescription The server-side map declaration.
174:             * @jsptagref.databindable false
175:             * @jsptagref.attributesyntaxvalue <i>string_isMap</i>
176:             * @netui:attribute required="false" rtexprvalue="true"
177:             * description="The server-side map declaration."
178:             */
179:            public void setIsmap(String ismap) {
180:                _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ISMAP,
181:                        ismap);
182:            }
183:
184:            /**
185:             * Sets the location hash to append to the url.
186:             * @param location the location hash.
187:             * @jsptagref.attributedescription The location hash to append to the URL.
188:             * @jsptagref.databindable false
189:             * @jsptagref.attributesyntaxvalue <i>string_location</i>
190:             * @netui:attribute required="false" rtexprvalue="true"
191:             * description="The location hash to append to the URL."
192:             */
193:            public void setLocation(String location) {
194:                _location = location;
195:            }
196:
197:            /**
198:             * Sets the image source URI.
199:             * @param src the source URI.
200:             * @jsptagref.attributedescription The image source URI
201:             * @jsptagref.databindable Read Only
202:             * @jsptagref.attributesyntaxvalue <i>string_src</i>
203:             * @netui:attribute required="false" rtexprvalue="true"
204:             * description="The image source URI"
205:             */
206:            public void setSrc(String src) throws JspException {
207:                _state.src = src;
208:            }
209:
210:            /**
211:             * Sets the client-side image map declaration.
212:             * @param usemap the map declaration.
213:             * @jsptagref.attributedescription The client-side image map declaration
214:             * @jsptagref.databindable false
215:             * @jsptagref.attributesyntaxvalue <i>string_useMap</i>
216:             * @netui:attribute required="false" rtexprvalue="true"
217:             * description="The client-side image map declaration"
218:             */
219:            public void setUsemap(String usemap) {
220:                _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
221:                        USEMAP, usemap);
222:            }
223:
224:            /**
225:             * Sets the vertical spacing around the image.
226:             * @param vspace the vertical spacing.
227:             * @jsptagref.attributedescription The vertical spacing around the image.
228:             * @jsptagref.databindable Read Only
229:             * @jsptagref.attributesyntaxvalue <i>string_vspace</i>
230:             * @netui:attribute required="false" rtexprvalue="true"
231:             * description="The vertical spacing around the image."
232:             */
233:            public void setVspace(String vspace) {
234:                _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL,
235:                        VSPACE, vspace);
236:            }
237:
238:            /**
239:             * Sets the image width.
240:             * @param width the image width.
241:             * @jsptagref.attributedescription The image width.
242:             * @jsptagref.databindable Read Only
243:             * @jsptagref.attributesyntaxvalue <i>integer_pixelWidth</i>
244:             * @netui:attribute required="false" rtexprvalue="true"
245:             * description="The image width."
246:             */
247:            public void setWidth(String width) {
248:                _state.registerAttribute(AbstractHtmlState.ATTR_GENERAL, WIDTH,
249:                        width);
250:            }
251:
252:            /**
253:             * Adds a URL parameter to the generated hyperlink.
254:             * @param name  the name of the parameter to be added.
255:             * @param value the value of the parameter to be added (a String or String[]).
256:             * @param facet
257:             */
258:            public void addParameter(String name, Object value, String facet)
259:                    throws JspException {
260:                assert (name != null) : "Parameter 'name' must not be null";
261:
262:                if (_params == null) {
263:                    _params = new HashMap();
264:                }
265:                ParamHelper.addParam(_params, name, value);
266:            }
267:
268:            /**
269:             * Render the beginning of the IMG tag.
270:             * @throws JspException if a JSP exception has occurred
271:             */
272:            public int doStartTag() throws JspException {
273:                // Evaluate the body of this tag
274:                return EVAL_BODY_BUFFERED;
275:            }
276:
277:            /**
278:             * Render the end of the IMG tag.
279:             * @throws JspException if a JSP exception has occurred
280:             */
281:            public int doEndTag() throws JspException {
282:                ServletRequest req = pageContext.getRequest();
283:                String scriptId = null;
284:
285:                // report errors that may have occurred
286:                if (hasErrors())
287:                    return reportAndExit(EVAL_PAGE);
288:
289:                // Generate the name definition or image element
290:                String uri = null;
291:                if (_state.src != null) {
292:                    try {
293:                        uri = PageFlowTagUtils.rewriteResourceURL(pageContext,
294:                                _state.src, _params, _location);
295:                    } catch (URISyntaxException e) {
296:                        // report the error...
297:                        String s = Bundle.getString("Tags_Image_URLException",
298:                                new Object[] { _state.src, e.getMessage() });
299:                        registerTagError(s, e);
300:                    }
301:                }
302:
303:                if (uri != null) {
304:                    _state.src = ((HttpServletResponse) pageContext
305:                            .getResponse()).encodeURL(uri);
306:                }
307:
308:                // we assume that tagId will over have override id if both
309:                // are defined.
310:                if (_state.id != null) {
311:                    scriptId = renderNameAndId((HttpServletRequest) req,
312:                            _state, null);
313:                }
314:
315:                WriteRenderAppender writer = new WriteRenderAppender(
316:                        pageContext);
317:                TagRenderingBase br = TagRenderingBase.Factory.getRendering(
318:                        TagRenderingBase.IMAGE_TAG, req);
319:                br.doStartTag(writer, _state);
320:                br.doEndTag(writer);
321:
322:                if (scriptId != null)
323:                    write(scriptId);
324:
325:                // Evaluate the remainder of this page
326:                localRelease();
327:                return EVAL_PAGE;
328:            }
329:
330:            /**
331:             * Release any acquired resources.
332:             */
333:            protected void localRelease() {
334:                super.localRelease();
335:
336:                _state.clear();
337:
338:                _location = null;
339:                _params = null;
340:            }
341:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.