Source Code Cross Referenced for BreadcrumbsTag.java in  » Portal » Open-Portal » com » ecyrd » jspwiki » tags » 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 » Portal » Open Portal » com.ecyrd.jspwiki.tags 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:            JSPWiki - a JSP-based WikiWiki clone.
003:
004:            Copyright (C) 2001-2003 Janne Jalkanen (Janne.Jalkanen@iki.fi)
005:
006:            This program is free software; you can redistribute it and/or modify
007:            it under the terms of the GNU Lesser General Public License as published by
008:            the Free Software Foundation; either version 2.1 of the License, or
009:            (at your option) any later version.
010:
011:            This program 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
014:            GNU Lesser General Public License for more details.
015:
016:            You should have received a copy of the GNU Lesser General Public License
017:            along with this program; if not, write to the Free Software
018:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         */
020:        package com.ecyrd.jspwiki.tags;
021:
022:        import com.ecyrd.jspwiki.WikiEngine;
023:        import com.ecyrd.jspwiki.WikiContext;
024:
025:        import javax.servlet.http.HttpSession;
026:        import javax.servlet.jsp.JspWriter;
027:
028:        import org.apache.log4j.Logger;
029:
030:        import java.io.IOException;
031:        import java.io.Serializable;
032:        import java.util.LinkedList;
033:
034:        /**
035:         * Implement a "breadcrumb" (most recently visited) trail.  This tag can be added to any view jsp page.
036:         * Separate breadcrumb trails are not tracked across multiple browser windows.<br>
037:         * The optional attributes are:
038:         * <p>
039:         * <b>maxpages</b>, the number of pages to store, 10 by default<br>
040:         * <b>separator</b>, the separator string to use between pages, " | " by default<br>
041:         * </p>
042:         *
043:         * <p>
044:         * This class is implemented by storing a breadcrumb trail, which is a 
045:         * fixed size queue, into a session variable "breadCrumbTrail".  
046:         * This queue is displayed as a series of links separated by a separator
047:         * character.
048:         * </p>
049:         * @author Ken Liu ken@kenliu.net
050:         */
051:        public class BreadcrumbsTag extends WikiTagBase {
052:            private static final Logger log = Logger
053:                    .getLogger(BreadcrumbsTag.class);
054:            private static final String BREADCRUMBTRAIL_KEY = "breadCrumbTrail";
055:            private int m_maxQueueSize = 11;
056:            private String m_separator = " > ";
057:
058:            public int getMaxpages() {
059:                return m_maxQueueSize;
060:            }
061:
062:            public void setMaxpages(int maxpages) {
063:                m_maxQueueSize = maxpages + 1;
064:            }
065:
066:            public String getSeparator() {
067:                return m_separator;
068:            }
069:
070:            public void setSeparator(String separator) {
071:                m_separator = separator;
072:            }
073:
074:            public final int doWikiStartTag() throws IOException {
075:                HttpSession session = pageContext.getSession();
076:                FixedQueue trail = (FixedQueue) m_wikiContext
077:                        .getPrivateSessionAttribute(BREADCRUMBTRAIL_KEY);
078:
079:                String page = m_wikiContext.getPage().getName();
080:
081:                if (trail == null) {
082:                    trail = new FixedQueue(m_maxQueueSize);
083:                }
084:
085:                if (m_wikiContext.getRequestContext().equals(WikiContext.VIEW)) {
086:                    if (trail.isEmpty()) {
087:                        trail.push(page);
088:                    } else {
089:                        //
090:                        // Don't add the page to the queue if the page was just refreshed
091:                        //
092:                        if (!((String) trail.getLast()).equals(page)) {
093:                            trail.push(page);
094:                            log.debug("added page: " + page);
095:                        }
096:                        log.debug("didn't add page because of refresh");
097:                    }
098:                }
099:
100:                m_wikiContext.setPrivateSessionAttribute(BREADCRUMBTRAIL_KEY,
101:                        trail);
102:
103:                //
104:                //  Print out the breadcrumb trail
105:                //
106:
107:                // FIXME: this code would be much simpler if we could just output the [pagename] and then use the
108:                // wiki engine to output the appropriate wikilink
109:
110:                JspWriter out = pageContext.getOut();
111:                int queueSize = trail.size();
112:                String linkclass = "wikipage";
113:                WikiEngine engine = m_wikiContext.getEngine();
114:                String curPage = null;
115:
116:                for (int i = 0; i < queueSize; i++) {
117:                    curPage = (String) trail.get(i);
118:
119:                    // skip the last page if it is the current page
120:                    if (i == queueSize - 1 && curPage.equals(page))
121:                        break;
122:
123:                    if (i > 0) {
124:                        out.print(m_separator);
125:                    }
126:
127:                    //FIXME: I can't figure out how to detect the appropriate jsp page to put here, so I hard coded Wiki.jsp
128:                    //This breaks when you view an attachment metadata page
129:                    out.print("<a class=\"" + linkclass + "\" href=\""
130:                            + m_wikiContext.getViewURL(curPage) + "\">"
131:                            + WikiEngine.getRelativeToWikiPageName(curPage)
132:                            + "</a>");
133:
134:                }
135:
136:                return SKIP_BODY;
137:            }
138:
139:            /**
140:             * Extends the LinkedList class to provide a fixed-size queue implementation
141:             */
142:            private static class FixedQueue extends LinkedList implements 
143:                    Serializable {
144:                private int m_size;
145:
146:                FixedQueue(int size) {
147:                    m_size = size;
148:                }
149:
150:                Object push(Object o) {
151:                    add(o);
152:                    if (size() > m_size)
153:                        return removeFirst();
154:                    else
155:                        return null;
156:                }
157:            }
158:
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.