Source Code Cross Referenced for JonasButtonTag.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » webapp » taglib » 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 » JOnAS 4.8.6 » org.objectweb.jonas.webapp.taglib 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: JonasButtonTag.java 6498 2005-04-01 09:57:23Z kemlerp $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.webapp.taglib;
027:
028:        import java.lang.reflect.InvocationTargetException;
029:
030:        import javax.servlet.jsp.JspException;
031:
032:        import org.apache.commons.beanutils.PropertyUtils;
033:        import org.apache.struts.taglib.html.LinkTag;
034:        import org.apache.struts.taglib.TagUtils;
035:        import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
036:
037:        /**
038:         * @author Michel-Ange ANTON
039:         */
040:        public class JonasButtonTag extends LinkTag {
041:
042:            // ----------------------------------------------------- Manifest Constants
043:
044:            private static final String s_ImageBorder = "dot.gif";
045:
046:            // ----------------------------------------------------- Instance Variables
047:
048:            protected String ms_PathImage = null;
049:            protected String ms_LastStyleClass = null;
050:            protected String ms_StyleClassButton = "btn";
051:
052:            // ------------------------------------------------------------- Properties
053:
054:            private int widthBorder = 1;
055:            private int heightBorder = 1;
056:            private String imagesDir = null;
057:            private String styleClassBorderLight = "btnBorderLight";
058:            private String styleClassBorderShadow = "btnBorderShadow";
059:            private String styleClassBackground = "btn";
060:            private String styleClassDisabled = "btnDisabled";
061:            private String disabledName = null;
062:            private String disabledProperty = null;
063:            private String disabledValueEqual = null;
064:            private String disabledValueNotEqual = null;
065:
066:            public int getHeightBorder() {
067:                return heightBorder;
068:            }
069:
070:            public void setHeightBorder(int heightBorder) {
071:                this .heightBorder = heightBorder;
072:            }
073:
074:            public String getImagesDir() {
075:                return imagesDir;
076:            }
077:
078:            public void setImagesDir(String imagesDir) {
079:                this .imagesDir = imagesDir;
080:            }
081:
082:            public int getWidthBorder() {
083:                return widthBorder;
084:            }
085:
086:            public void setWidthBorder(int widthBorder) {
087:                this .widthBorder = widthBorder;
088:            }
089:
090:            public String getStyleClassBorderLight() {
091:                return styleClassBorderLight;
092:            }
093:
094:            public void setStyleClassBorderLight(String styleClassBorderLight) {
095:                this .styleClassBorderLight = styleClassBorderLight;
096:            }
097:
098:            public String getStyleClassBorderShadow() {
099:                return styleClassBorderShadow;
100:            }
101:
102:            public void setStyleClassBorderShadow(String styleClassBorderShadow) {
103:                this .styleClassBorderShadow = styleClassBorderShadow;
104:            }
105:
106:            public String getStyleClassBackground() {
107:                return styleClassBackground;
108:            }
109:
110:            public void setStyleClassBackground(String styleClassBackground) {
111:                this .styleClassBackground = styleClassBackground;
112:            }
113:
114:            public String getStyleClassDisabled() {
115:                return styleClassDisabled;
116:            }
117:
118:            public void setStyleClassDisabled(String styleClassDisabled) {
119:                this .styleClassDisabled = styleClassDisabled;
120:            }
121:
122:            public String getDisabledName() {
123:                return disabledName;
124:            }
125:
126:            public void setDisabledName(String disabledName) {
127:                this .disabledName = disabledName;
128:            }
129:
130:            public String getDisabledProperty() {
131:                return disabledProperty;
132:            }
133:
134:            public void setDisabledProperty(String disabledProperty) {
135:                this .disabledProperty = disabledProperty;
136:            }
137:
138:            public String getDisabledValueEqual() {
139:                return disabledValueEqual;
140:            }
141:
142:            public void setDisabledValueEqual(String disabledValueEqual) {
143:                this .disabledValueEqual = disabledValueEqual;
144:            }
145:
146:            public String getDisabledValueNotEqual() {
147:                return disabledValueNotEqual;
148:            }
149:
150:            public void setDisabledValueNotEqual(String disabledValueNotEqual) {
151:                this .disabledValueNotEqual = disabledValueNotEqual;
152:            }
153:
154:            // ------------------------------------------------------------- Public methods
155:
156:            /**
157:             * Render the beginning of the hyperlink.
158:             *
159:             * @exception JspException if a JSP exception has occurred
160:             */
161:            public int doStartTag() throws JspException {
162:
163:                // Test if button disabled
164:                boolean bDisabled = getDisabled();
165:                TagUtils tagUtils = TagUtils.getInstance();
166:                if ((getDisabledName() != null)
167:                        && ((getDisabledValueEqual() != null) || (getDisabledValueNotEqual() != null))) {
168:                    String sValue = lookupProperty(getDisabledName(),
169:                            getDisabledProperty());
170:                    if (getDisabledValueEqual() != null) {
171:                        bDisabled = getDisabledValueEqual().equals(sValue);
172:                    } else {
173:                        bDisabled = !getDisabledValueNotEqual().equals(sValue);
174:                    }
175:                }
176:
177:                // Force style class to the Link Tag
178:                ms_LastStyleClass = getStyleClass();
179:                if (getStyleClass() == null) {
180:                    setStyleClass(ms_StyleClassButton);
181:                }
182:                // Prepare path image
183:                makePathImage();
184:                // Add the begining of render button
185:                StringBuffer sb = new StringBuffer(
186:                        "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
187:                sb.append(prepareBorderTop());
188:                sb.append("<tr>");
189:                sb.append(prepareBorderColumn(styleClassBorderLight));
190:                sb.append("<td nowrap class=\"");
191:                if (bDisabled == false) {
192:                    sb.append(styleClassBackground);
193:                } else {
194:                    sb.append(styleClassDisabled);
195:                }
196:                sb.append("\">");
197:                tagUtils.write(pageContext, sb.toString());
198:
199:                if (bDisabled == false) {
200:                    // Add link if enabled
201:                    return (super .doStartTag());
202:                }
203:                return (EVAL_BODY_BUFFERED);
204:            }
205:
206:            /**
207:             * Render the end of the hyperlink.
208:             *
209:             * @exception JspException if a JSP exception has occurred
210:             */
211:            public int doEndTag() throws JspException {
212:                StringBuffer sb = new StringBuffer();
213:                int iRet = EVAL_PAGE;
214:                TagUtils tagUtils = TagUtils.getInstance();
215:
216:                // If body text exist pre-fix and post-fix with space
217:                if (text != null) {
218:                    StringBuffer sbText = new StringBuffer("&nbsp;");
219:                    sbText.append(text);
220:                    sbText.append("&nbsp;");
221:                    text = sbText.toString();
222:                }
223:
224:                if (getDisabled() == false) {
225:                    // Add link if enabled
226:                    iRet = super .doEndTag();
227:                } else {
228:                    sb.append(text);
229:                }
230:
231:                // Add the end of render button
232:                sb.append("</td>");
233:                sb.append(prepareBorderColumn(styleClassBorderShadow));
234:                sb.append("</tr>");
235:                sb.append(prepareBorderBottom());
236:                sb.append("</table>");
237:                tagUtils.write(pageContext, sb.toString());
238:
239:                // Force last style
240:                setStyleClass(ms_LastStyleClass);
241:                ms_LastStyleClass = null;
242:
243:                return (iRet);
244:            }
245:
246:            public String getImagesRoot() {
247:                String sImagesRoot = null;
248:                WhereAreYou oWhere = getWhereAreYouInstance();
249:                if (oWhere != null) {
250:                    sImagesRoot = oWhere.getImagesRoot();
251:                }
252:                return sImagesRoot;
253:            }
254:
255:            public void release() {
256:                super .release();
257:                ms_PathImage = null;
258:                imagesDir = null;
259:                ms_StyleClassButton = null;
260:                styleClassBorderLight = null;
261:                styleClassBorderShadow = null;
262:                styleClassBackground = null;
263:                styleClassDisabled = null;
264:            }
265:
266:            // --------------------------------------------------------- Protected Methods
267:            protected void makePathImage() {
268:                // Prepare image separator
269:                if (imagesDir != null) {
270:                    ms_PathImage = imagesDir + "/" + s_ImageBorder;
271:                } else if (getImagesRoot() != null) {
272:                    ms_PathImage = getImagesRoot() + "/" + s_ImageBorder;
273:                } else {
274:                    ms_PathImage = s_ImageBorder;
275:                }
276:            }
277:
278:            /**
279:             * Return render image.
280:             * @return
281:             */
282:            protected String prepareImage() {
283:                StringBuffer sb = new StringBuffer("<img src=\"");
284:                sb.append(ms_PathImage);
285:                sb.append("\" width=\"");
286:                sb.append(widthBorder);
287:                sb.append("\" height=\"");
288:                sb.append(heightBorder);
289:                sb.append("\" border=\"0\">");
290:                return sb.toString();
291:            }
292:
293:            /**
294:             * Return render image.
295:             * @return
296:             */
297:            protected String prepareBorderColumn(String ps_Class) {
298:                StringBuffer sb = new StringBuffer("<td width=\"");
299:                sb.append(widthBorder);
300:                sb.append("\" height=\"");
301:                sb.append(heightBorder);
302:                sb.append("\" class=\"");
303:                //btnBorderLight
304:                sb.append(ps_Class);
305:                sb.append("\">");
306:                sb.append(prepareImage());
307:                sb.append("</td>");
308:                return sb.toString();
309:            }
310:
311:            protected String prepareBorderTop() {
312:                StringBuffer sb = new StringBuffer("<tr>");
313:                sb.append(prepareBorderColumn(styleClassBorderLight));
314:                sb.append(prepareBorderColumn(styleClassBorderLight));
315:                sb.append(prepareBorderColumn(styleClassBorderLight));
316:                sb.append("</tr>");
317:                return sb.toString();
318:            }
319:
320:            protected String prepareBorderBottom() {
321:                StringBuffer sb = new StringBuffer("<tr>");
322:                sb.append(prepareBorderColumn(styleClassBorderLight));
323:                sb.append(prepareBorderColumn(styleClassBorderShadow));
324:                sb.append(prepareBorderColumn(styleClassBorderShadow));
325:                sb.append("</tr>");
326:                return sb.toString();
327:            }
328:
329:            protected WhereAreYou getWhereAreYouInstance() {
330:                return (WhereAreYou) pageContext.getSession().getAttribute(
331:                        WhereAreYou.SESSION_NAME);
332:            }
333:
334:            protected String lookupProperty(String beanName, String property)
335:                    throws JspException {
336:
337:                TagUtils tagUtils = TagUtils.getInstance();
338:                Object bean = tagUtils.lookup(this .pageContext, beanName, null);
339:                if (bean == null) {
340:                    throw new JspException(messages.getMessage("getter.bean",
341:                            beanName));
342:                }
343:                if (property == null) {
344:                    return bean.toString();
345:                }
346:                try {
347:                    return (PropertyUtils.getProperty(bean, property))
348:                            .toString();
349:                } catch (IllegalAccessException e) {
350:                    throw new JspException(messages.getMessage("getter.access",
351:                            property, beanName));
352:
353:                } catch (InvocationTargetException e) {
354:                    Throwable t = e.getTargetException();
355:                    throw new JspException(messages.getMessage("getter.result",
356:                            property, t.toString()));
357:
358:                } catch (NoSuchMethodException e) {
359:                    throw new JspException(messages.getMessage("getter.method",
360:                            property, beanName));
361:                }
362:            }
363:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.