Source Code Cross Referenced for BookmarkablePageLink.java in  » J2EE » wicket » wicket » markup » html » link » 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 » wicket » wicket.markup.html.link 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: BookmarkablePageLink.java 462394 2006-09-28 16:22:10Z ehillenius $
003:         * $Revision: 462394 $ $Date: 2006-09-28 18:22:10 +0200 (Thu, 28 Sep 2006) $
004:         * 
005:         * ==============================================================================
006:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
007:         * use this file except in compliance with the License. You may obtain a copy of
008:         * the License at
009:         * 
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
014:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
015:         * License for the specific language governing permissions and limitations under
016:         * the License.
017:         */
018:        package wicket.markup.html.link;
019:
020:        import wicket.AttributeModifier;
021:        import wicket.Page;
022:        import wicket.PageMap;
023:        import wicket.PageParameters;
024:        import wicket.model.Model;
025:
026:        /**
027:         * Renders a stable link which can be cached in a web browser and used at a
028:         * later time.
029:         * 
030:         * @author Jonathan Locke
031:         */
032:        public class BookmarkablePageLink extends Link {
033:            private static final long serialVersionUID = 1L;
034:
035:            /** The page class that this link links to. */
036:            private final Class pageClass;
037:
038:            /** Any page map for this link */
039:            private String pageMapName = null;
040:
041:            /** The parameters to pass to the class constructor when instantiated. */
042:            private final PageParameters parameters;
043:
044:            /**
045:             * Constructor.
046:             * 
047:             * @param id
048:             *            The name of this component
049:             * @param pageClass
050:             *            The class of page to link to
051:             */
052:            public BookmarkablePageLink(final String id, final Class pageClass) {
053:                this (id, pageClass, new PageParameters());
054:            }
055:
056:            /**
057:             * Constructor.
058:             * 
059:             * @param id
060:             *            See Component
061:             * @param pageClass
062:             *            The class of page to link to
063:             * @param parameters
064:             *            The parameters to pass to the new page when the link is
065:             *            clicked
066:             */
067:            public BookmarkablePageLink(final String id, final Class pageClass,
068:                    final PageParameters parameters) {
069:                super (id);
070:                if (pageClass == null) {
071:                    throw new IllegalArgumentException(
072:                            "Page class for bookmarkable link cannot be null");
073:                } else if (!Page.class.isAssignableFrom(pageClass)) {
074:                    throw new IllegalArgumentException(
075:                            "Page class must be derived from "
076:                                    + Page.class.getName());
077:                }
078:                this .pageClass = pageClass;
079:                this .parameters = parameters;
080:            }
081:
082:            /**
083:             * Get tge page class registered with the link
084:             * 
085:             * @return Page class
086:             */
087:            public final Class getPageClass() {
088:                return this .pageClass;
089:            }
090:
091:            /**
092:             * @return Page map for this link
093:             */
094:            public final PageMap getPageMap() {
095:                if (pageMapName != null) {
096:                    return PageMap.forName(pageMapName);
097:                } else {
098:                    return getPage().getPageMap();
099:                }
100:            }
101:
102:            /**
103:             * Whether this link refers to the given page.
104:             * 
105:             * @param page
106:             *            the page
107:             * @see wicket.markup.html.link.Link#linksTo(wicket.Page)
108:             */
109:            public boolean linksTo(final Page page) {
110:                return page.getClass() == pageClass;
111:            }
112:
113:            /**
114:             * THIS METHOD IS NOT USED! Bookmarkable links do not have a click handler.
115:             * It is here to satisfy the interface only, as bookmarkable links will be
116:             * dispatched by the handling servlet.
117:             * 
118:             * @see wicket.markup.html.link.Link#onClick()
119:             */
120:            public final void onClick() {
121:                // Bookmarkable links do not have a click handler.
122:                // Instead they are dispatched by the request handling servlet.
123:            }
124:
125:            /**
126:             * @param pageMap
127:             *            The pagemap for this link's destination
128:             * @return This
129:             */
130:            public final BookmarkablePageLink setPageMap(final PageMap pageMap) {
131:                this .pageMapName = pageMap.getName();
132:                if (pageMap != null) {
133:                    add(new AttributeModifier("target", false, new Model(
134:                            pageMapName)));
135:                }
136:                return this ;
137:            }
138:
139:            /**
140:             * Adds a given page property value to this link.
141:             * 
142:             * @param property
143:             *            The property
144:             * @param value
145:             *            The value
146:             * @return This
147:             */
148:            public BookmarkablePageLink setParameter(final String property,
149:                    final int value) {
150:                parameters.put(property, Integer.toString(value));
151:                return this ;
152:            }
153:
154:            /**
155:             * Adds a given page property value to this link.
156:             * 
157:             * @param property
158:             *            The property
159:             * @param value
160:             *            The value
161:             * @return This
162:             */
163:            public BookmarkablePageLink setParameter(final String property,
164:                    final long value) {
165:                parameters.put(property, Long.toString(value));
166:                return this ;
167:            }
168:
169:            /**
170:             * Adds a given page property value to this link.
171:             * 
172:             * @param property
173:             *            The property
174:             * @param value
175:             *            The value
176:             * @return This
177:             */
178:            public BookmarkablePageLink setParameter(final String property,
179:                    final String value) {
180:                parameters.put(property, value);
181:                return this ;
182:            }
183:
184:            /**
185:             * Gets the url to use for this link.
186:             * 
187:             * @return The URL that this link links to
188:             * @see wicket.markup.html.link.Link#getURL()
189:             */
190:            protected CharSequence getURL() {
191:                if (pageMapName != null && getPopupSettings() != null) {
192:                    throw new IllegalStateException(
193:                            "You cannot specify popup settings and a page map");
194:                }
195:
196:                if (getPopupSettings() != null) {
197:                    return urlFor(getPopupSettings().getPageMap(this),
198:                            pageClass, parameters);
199:                } else {
200:                    return urlFor(getPageMap(), pageClass, parameters);
201:                }
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.