Source Code Cross Referenced for TitleContentTag.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: TitleContentTag.java 4408 2004-03-19 14:31:54Z sauthieg $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.webapp.taglib;
027:
028:        import java.io.IOException;
029:        import java.util.ArrayList;
030:
031:        import javax.servlet.http.HttpServletRequest;
032:        import javax.servlet.http.HttpServletResponse;
033:        import javax.servlet.jsp.JspException;
034:        import javax.servlet.jsp.JspWriter;
035:
036:        /**
037:         * @author Michel-Ange ANTON
038:         */
039:        public class TitleContentTag extends WhereAreYouTag {
040:
041:            // ----------------------------------------------------- Constants
042:
043:            // ----------------------------------------------------- Instance Variables
044:
045:            protected String m_Body = null;
046:
047:            // ------------------------------------------------------------- Properties
048:            private String image = null;
049:            private String title = null;
050:            private boolean usingParent = false;
051:            private boolean tomThumb = false;
052:            private boolean tomThumbIcons = false;
053:
054:            public String getImage() {
055:                return image;
056:            }
057:
058:            public void setImage(String image) {
059:                this .image = image;
060:            }
061:
062:            public String getTitle() {
063:                return title;
064:            }
065:
066:            public void setTitle(String title) {
067:                this .title = title;
068:            }
069:
070:            public boolean isUsingParent() {
071:                return usingParent;
072:            }
073:
074:            public void setUsingParent(boolean usingParent) {
075:                this .usingParent = usingParent;
076:            }
077:
078:            public boolean isTomThumb() {
079:                return tomThumb;
080:            }
081:
082:            public void setTomThumb(boolean tomThumb) {
083:                this .tomThumb = tomThumb;
084:            }
085:
086:            public boolean isTomThumbIcons() {
087:                return tomThumbIcons;
088:            }
089:
090:            public void setTomThumbIcons(boolean tomThumbIcons) {
091:                this .tomThumbIcons = tomThumbIcons;
092:            }
093:
094:            // --------------------------------------------------------- Public Methods
095:
096:            /**
097:             * Render this instant actions control.
098:             *
099:             * @return Constant EVAL_PAGE
100:             * @exception JspException if a processing error occurs
101:             */
102:            public int doEndTag() throws JspException {
103:                JspWriter out = pageContext.getOut();
104:                try {
105:                    render(out);
106:                } catch (IOException e) {
107:                    throw new JspException(e);
108:                }
109:                return (EVAL_PAGE);
110:            }
111:
112:            public int doAfterBody() throws JspException {
113:                String sBody = bodyContent.getString();
114:                if (sBody != null) {
115:                    sBody = sBody.trim();
116:                    if (sBody.length() > 0) {
117:                        this .m_Body = sBody;
118:                    }
119:                }
120:                return (SKIP_BODY);
121:            }
122:
123:            /**
124:             * Release all state information set by this tag.
125:             */
126:            public void release() {
127:                this .image = null;
128:                this .title = null;
129:                m_Body = null;
130:            }
131:
132:            // -------------------------------------------------------- Protected Methods
133:
134:            protected void render(JspWriter out) throws IOException,
135:                    JspException {
136:                String sImageDisplay = null;
137:                String sTitleDisplay = null;
138:                ArrayList alTomThumb = null;
139:                //String sThumbDisplay = null;
140:
141:                // Prepare WhereAreYou infos
142:                if (isUsingWhere()) {
143:                    TreeControlNode oNode = getSelectedTreeControlNode();
144:                    if (oNode != null) {
145:                        sImageDisplay = getImagesRoot() + "/" + oNode.getIcon();
146:                        sTitleDisplay = oNode.getLabel();
147:                        // Prepare label of parent node
148:                        if (isUsingParent() == true) {
149:                            TreeControlNode oParent = oNode.getParent();
150:                            if (oParent != null) {
151:                                sTitleDisplay = oParent.getLabel() + " : "
152:                                        + oNode.getLabel();
153:                            }
154:                        }
155:                        // Prepare Tom Thumb list
156:                        if (isTomThumb() == true) {
157:                            alTomThumb = getTomThumbList(oNode);
158:                        }
159:                    }
160:                }
161:                // Prepare parameters
162:                if (image != null) {
163:                    sImageDisplay = image;
164:                }
165:                if (title != null) {
166:                    sTitleDisplay = title;
167:                }
168:                if (m_Body != null) {
169:                    sTitleDisplay = m_Body;
170:                    m_Body = null;
171:                }
172:                // Display
173:                if ((sImageDisplay != null) || (sTitleDisplay != null)) {
174:                    String sTomThumb = null;
175:                    // Build Tom Thumb display
176:                    if (alTomThumb != null) {
177:                        if (alTomThumb.size() > 0) {
178:                            sTomThumb = renderTomThumb(alTomThumb);
179:                        }
180:                    }
181:                    // Display Tom Thumb
182:                    if (sTomThumb != null) {
183:                        out
184:                                .println("<table height=\"50\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
185:                        out.print("<tr valign=\"top\">");
186:                        out
187:                                .print("<td class=\"contentTitleTomThumb\" colspan=\"3\">");
188:                        out.print(sTomThumb);
189:                        out.print("</td>");
190:                        out.println("</tr>");
191:                    } else {
192:                        // No Tom Thumb to display
193:                        out
194:                                .println("<table height=\"30\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">");
195:                    }
196:                    // Display icon
197:                    out.println("<tr valign=\"top\">");
198:                    if (sImageDisplay != null) {
199:                        out
200:                                .print("<td width=\"1%\" valign=\"top\" class=\"contentTitleImage\"><img src=\"");
201:                        out.print(sImageDisplay);
202:                        out.println("\" border=\"0\"></td>");
203:                        out
204:                                .println("<td width=\"1%\" valign=\"top\" class=\"contentTitleImage\">&nbsp;</td>");
205:                    }
206:                    // Display title
207:                    if (sTitleDisplay != null) {
208:                        out.print("<td class=\"contentTitle\">");
209:                        out.print(sTitleDisplay);
210:                        out.println("</td>");
211:                    }
212:                    out.println("</tr>");
213:                    out.println("</table>");
214:                }
215:            }
216:
217:            protected String renderTomThumb(ArrayList p_TomThumb) {
218:                StringBuffer sb = new StringBuffer();
219:                ItemTomThumb oThumb;
220:                for (int i = p_TomThumb.size() - 1; i >= 0; i--) {
221:                    oThumb = (ItemTomThumb) p_TomThumb.get(i);
222:                    if (oThumb.getLink() != null) {
223:                        sb.append("<a href=\"");
224:                        sb.append(oThumb.getLink());
225:                        sb.append("\" class=\"contentTitleTomThumb\">");
226:                        if ((isTomThumbIcons() == true)
227:                                && (oThumb.getIcon() != null)) {
228:                            sb.append("<img src=\"");
229:                            sb.append(getImagesRoot());
230:                            sb.append("/");
231:                            sb.append(oThumb.getIcon());
232:                            sb.append("\" border=\"0\"> ");
233:                        }
234:                        sb.append(oThumb.getLabel());
235:                        sb.append("</a>");
236:                    } else {
237:                        if ((isTomThumbIcons() == true)
238:                                && (oThumb.getIcon() != null)) {
239:                            sb.append("<img src=\"");
240:                            sb.append(oThumb.getIcon());
241:                            sb.append("\" border=\"0\"> ");
242:                        }
243:                        sb
244:                                .append("<span class=\"contentTitleTomThumbNotLink\">");
245:                        sb.append(oThumb.getLabel());
246:                        sb.append("</span>");
247:                    }
248:                    if (i > 0) {
249:                        sb.append(" > ");
250:                    }
251:                }
252:                return sb.toString();
253:            }
254:
255:            protected ArrayList getTomThumbList(TreeControlNode p_Node) {
256:                TreeControlNode oParent;
257:                ItemTomThumb oThumb;
258:
259:                TreeControlNode oNode = p_Node;
260:                ArrayList alTomThumb = new ArrayList();
261:                // Loop on each parent
262:                do {
263:                    // Get parent
264:                    oParent = oNode.getParent();
265:                    // Verify parent exist
266:                    if (oParent != null) {
267:                        // Verify parent is not empty or root node
268:                        if (("ROOT-NODE".equalsIgnoreCase(oParent.getName()) == false)
269:                                && (oParent.getLabel() != null)) {
270:                            // Get Thumb infos
271:                            oThumb = new ItemTomThumb();
272:                            oThumb.setLabel(oParent.getLabel());
273:                            oThumb.setIcon(oParent.getIcon());
274:                            if (oParent.getAction() != null) {
275:                                oThumb
276:                                        .setLink(((HttpServletResponse) pageContext
277:                                                .getResponse())
278:                                                .encodeURL(((HttpServletRequest) pageContext
279:                                                        .getRequest())
280:                                                        .getContextPath()
281:                                                        + "/"
282:                                                        + oParent.getAction()));
283:                            }
284:                            // Add to thumb's list
285:                            alTomThumb.add(oThumb);
286:                        }
287:                    }
288:                    // Next parent
289:                    oNode = oParent;
290:                } while (oParent != null);
291:
292:                return alTomThumb;
293:            }
294:
295:            class ItemTomThumb {
296:                private String label = null;
297:                private String link = null;
298:                private String icon = null;
299:
300:                public ItemTomThumb() {
301:
302:                }
303:
304:                public ItemTomThumb(String p_Label, String p_Link, String p_Icon) {
305:                    setLabel(p_Label);
306:                    setLink(p_Link);
307:                    setIcon(p_Icon);
308:                }
309:
310:                public String getLabel() {
311:                    return label;
312:                }
313:
314:                public void setLabel(String label) {
315:                    this .label = label;
316:                }
317:
318:                public String getLink() {
319:                    return link;
320:                }
321:
322:                public void setLink(String link) {
323:                    this .link = link;
324:                }
325:
326:                public String getIcon() {
327:                    return icon;
328:                }
329:
330:                public void setIcon(String icon) {
331:                    this.icon = icon;
332:                }
333:
334:            }
335:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.