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


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