Source Code Cross Referenced for JspBrandingImage.java in  » J2EE » Sofia » com » salmonllc » jsp » 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 » J2EE » Sofia » com.salmonllc.jsp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //** Copyright Statement ***************************************************
002:        //The Salmon Open Framework for Internet Applications (SOFIA)
003:        // Copyright (C) 1999 - 2002, Salmon LLC
004:        //
005:        // This program is free software; you can redistribute it and/or
006:        // modify it under the terms of the GNU General Public License version 2
007:        // as published by the Free Software Foundation;
008:        // 
009:        // This program is distributed in the hope that it will be useful,
010:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
011:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:        // GNU General Public License for more details.
013:        // 
014:        // You should have received a copy of the GNU General Public License
015:        // along with this program; if not, write to the Free Software
016:        // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:        // 
018:        // For more information please visit http://www.salmonllc.com
019:        //** End Copyright Statement ***************************************************
020:        package com.salmonllc.jsp;
021:
022:        /////////////////////////
023:        //$Archive: /SOFIA/SourceCode/com/salmonllc/jsp/JspBrandingImage.java $
024:        //$Author: Srufle $
025:        //$Revision: 14 $
026:        //$Modtime: 4/15/03 2:24p $
027:        /////////////////////////
028:
029:        import java.util.Vector;
030:
031:        import com.salmonllc.html.HtmlImage;
032:        import com.salmonllc.html.events.PageEvent;
033:        import com.salmonllc.html.events.PageListener;
034:        import com.salmonllc.sql.DataStore;
035:
036:        /**
037:         *	This class is used to display a differet image from a series of images on every request to 
038:         *  the page.  It cycles through the different images to display a new image
039:         *	wherever this tag is placed on the page, so as to give a more dynamic look
040:         *	and feel to the website.
041:         */
042:
043:        public class JspBrandingImage extends HtmlImage implements  PageListener {
044:            private String _tableName = "BRAND";
045:            private String _imageColumn = "IMAGE";
046:            private String _imageAltColumn = "IMAGE_ALT";
047:            private String _fImageDir = "images";
048:
049:            /*
050:             * This inner class is used to hold and manipulate the list of branding
051:             * images as stored in the database. 
052:             */
053:            private class BrandImageList {
054:                private Vector _images = new Vector();
055:                private int _nextImage = 0;
056:
057:                /**
058:                 * BrandImageList constructor.  This inner class is meant to be a
059:                 * container of all of the branding images stored in the database.
060:                 * This class acts on a Vector to store the list of images.
061:                 */
062:                public BrandImageList() {
063:                    super ();
064:                }
065:
066:                /**
067:                 * This method adds a String array containing the added image's url
068:                 * and alt tag
069:                 * @param url java.lang.String
070:                 * @param alt java.lang.String
071:                 */
072:                public void addImage(String url, String alt) {
073:                    String s[] = new String[2];
074:                    s[0] = url;
075:                    s[1] = alt;
076:                    _images.addElement(s);
077:                }
078:
079:                /**
080:                 * This method returns the current image's alt value
081:                 * @return java.lang.String
082:                 */
083:                public String getCurrentAlt() {
084:                    if (_images.size() == 0)
085:                        return null;
086:
087:                    String s[] = (String[]) _images.elementAt(_nextImage);
088:                    return s[1];
089:                }
090:
091:                /**
092:                 * This method returns the current image's url.
093:                 * @return java.lang.String
094:                 */
095:                public String getCurrentURL() {
096:                    if (_images.size() == 0)
097:                        return null;
098:
099:                    String s[] = (String[]) _images.elementAt(_nextImage);
100:                    return s[0];
101:                }
102:
103:                /**
104:                 *	This method increases the counter for the next image by 1,
105:                 * 	and sets the Vector to be on the first element if you want to
106:                 *	move up from the last element in the Vector.
107:                 * 	@return boolean
108:                 */
109:                public boolean nextImage() {
110:                    if (_images.size() == 0)
111:                        return false;
112:
113:                    if (_nextImage >= (_images.size() - 1))
114:                        _nextImage = 0;
115:                    else
116:                        _nextImage++;
117:
118:                    return true;
119:                }
120:            }
121:
122:            /**
123:             * BrandingImage constructor comment.
124:             * @param name java.lang.String
125:             * @param p com.salmonllc.jsp.JspController
126:             */
127:            public JspBrandingImage(String name, JspController p) {
128:                super ("", name, p);
129:                p.addPageListener(this );
130:            }
131:
132:            /**
133:             * This method is used to get the name of the DataBase Table's column that holds
134:             * the value of the image's alt tag.
135:             * @return java.lang.String
136:             */
137:            public String getImageAltColumn() {
138:                return _imageAltColumn;
139:            }
140:
141:            /**
142:             * This method is used to get the name of the DataBase Table's column that holds
143:             * the name of the images.
144:             * @return java.lang.String
145:             */
146:            public String getImageColumn() {
147:                return _imageColumn;
148:            }
149:
150:            /**
151:             * This method is used to get the directory in which images are stored.
152:             * @return java.lang.String
153:             */
154:            public java.lang.String getImageDir() {
155:                return _fImageDir;
156:            }
157:
158:            /**
159:             * This method is used to get the name of the DataBase Table.
160:             * @return java.lang.String
161:             */
162:            public java.lang.String getTableName() {
163:                return _tableName;
164:            }
165:
166:            /**
167:             * This method assumes that you have a Database Table named "brand", with the
168:             * columns "image" and "image_alt".  It also assumes that all images are stored
169:             * in the folder "JSP/AppName/images".  You can also change the Table name from
170:             * using the "TableName" attribute in the Brand tag.
171:             * Creation date: (2/6/02 10:12:03 AM)
172:             */
173:            public BrandImageList loadImages(JspController cont)
174:                    throws Exception {
175:                BrandImageList l = new BrandImageList();
176:
177:                DataStore ds = new DataStore(cont.getApplicationName());
178:                ds.addColumn(getTableName(), getImageColumn(),
179:                        DataStore.DATATYPE_STRING);
180:                ds.addColumn(getTableName(), getImageAltColumn(),
181:                        DataStore.DATATYPE_STRING);
182:                ds.retrieve();
183:
184:                for (int i = 0; i < ds.getRowCount(); i++)
185:                    l.addImage(getImageDir()
186:                            + "/"
187:                            + ds.getString(i, getTableName() + "."
188:                                    + getImageColumn()), ds.getString(i,
189:                            getTableName() + "." + getImageAltColumn()));
190:
191:                return l;
192:            }
193:
194:            /**
195:             * 	This method/event will get fired each time a page is requested by the browser.
196:             *	@param p PageEvent
197:             *	@throws Exception
198:             */
199:            public void pageRequested(PageEvent p) throws Exception {
200:                JspController cont = (JspController) p.getPage();
201:                javax.servlet.http.HttpSession sess = cont.getSession();
202:                BrandImageList l = (BrandImageList) sess
203:                        .getAttribute("BrandingImageList");
204:                if (l == null) {
205:                    l = loadImages(cont);
206:                    sess.setAttribute("BrandingImageList", l);
207:                } else
208:                    l.nextImage();
209:
210:                if (l.getCurrentURL() == null)
211:                    setVisible(false);
212:                else {
213:                    setVisible(true);
214:                    setSource(l.getCurrentURL());
215:                    setAlt(l.getCurrentAlt());
216:                }
217:
218:            }
219:
220:            /**
221:             * This event will get fired each time a page is requested by the browser.
222:             */
223:            public void pageRequestEnd(com.salmonllc.html.events.PageEvent p)
224:                    throws java.lang.Exception {
225:            }
226:
227:            /**
228:             * This method occurs eaxh time a page is sumbitted.
229:             */
230:            public void pageSubmitEnd(com.salmonllc.html.events.PageEvent p) {
231:            }
232:
233:            /**
234:             * This method occurs eaxh time a page is sumbitted.
235:             */
236:            public void pageSubmitted(com.salmonllc.html.events.PageEvent p) {
237:            }
238:
239:            /**
240:             * This method sets the name of the column in the DataBase that corresponds to
241:             * image alts, as this column holds the alt value for the images.
242:             * @param imageAltColumn java.lang.String
243:             */
244:            public void setImageAltColumn(String imageAltColumn) {
245:                _imageAltColumn = imageAltColumn;
246:            }
247:
248:            /**
249:             * This method sets the name of the column in the DataBase that correspond to
250:             * images, as this column holds the name of the images.
251:             * @param imageColumn java.lang.String
252:             */
253:            public void setImageColumn(String imageColumn) {
254:                _imageColumn = imageColumn;
255:            }
256:
257:            /**
258:             * This method sets the directory that the branding images reside in.
259:             * @param newImageDir java.lang.String
260:             */
261:            public void setImageDir(java.lang.String newImageDir) {
262:                _fImageDir = newImageDir;
263:            }
264:
265:            /**
266:             * This method sets the name of the DataBase Table.
267:             * @param TableName java.lang.String
268:             */
269:            public void setTableName(java.lang.String TableName) {
270:                _tableName = TableName;
271:            }
272:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.