Source Code Cross Referenced for BookmarkablePageRequestTarget.java in  » J2EE » wicket » wicket » request » target » component » 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.request.target.component 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: BookmarkablePageRequestTarget.java,v 1.3 2005/12/07 00:52:26 ivaynberg
003:         * Exp $ $Revision: 460676 $ $Date: 2006-05-22 23:13:27 +0200 (Mon, 22 May 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.request.target.component;
019:
020:        import wicket.IPageFactory;
021:        import wicket.Page;
022:        import wicket.PageParameters;
023:        import wicket.RequestCycle;
024:        import wicket.request.IRequestCycleProcessor;
025:
026:        /**
027:         * Default implementation of {@link IBookmarkablePageRequestTarget}. Target
028:         * that denotes a page that is to be created from the provided page class. This
029:         * is typically used for redirects to bookmarkable pages or mounted pages.
030:         * 
031:         * @author Eelco Hillenius
032:         * @author Igor Vaynberg (ivaynberg)
033:         */
034:        public class BookmarkablePageRequestTarget implements 
035:                IBookmarkablePageRequestTarget {
036:            /** the page that was created in response for cleanup */
037:            private Page page;
038:
039:            /** the class of the page. */
040:            private final Class pageClass;
041:
042:            /** optional page map name. */
043:            private final String pageMapName;
044:
045:            /** optional page parameters. */
046:            private final PageParameters pageParameters;
047:
048:            /**
049:             * Construct.
050:             * 
051:             * @param pageClass
052:             *            the class of the page
053:             */
054:            public BookmarkablePageRequestTarget(Class pageClass) {
055:                this (null, pageClass);
056:            }
057:
058:            /**
059:             * Construct.
060:             * 
061:             * @param pageClass
062:             *            the class of the page
063:             * @param pageParameters
064:             *            optional page parameters
065:             */
066:            public BookmarkablePageRequestTarget(Class pageClass,
067:                    PageParameters pageParameters) {
068:                this (null, pageClass, pageParameters);
069:            }
070:
071:            /**
072:             * Construct.
073:             * 
074:             * @param pageMapName
075:             *            optional page map name
076:             * 
077:             * @param pageClass
078:             *            the class of the page
079:             */
080:            public BookmarkablePageRequestTarget(String pageMapName,
081:                    Class pageClass) {
082:                this (null, pageClass, null);
083:            }
084:
085:            /**
086:             * Construct.
087:             * 
088:             * @param pageMapName
089:             *            optional page map name
090:             * @param pageClass
091:             *            the class of the page
092:             * @param pageParameters
093:             *            optional page parameters
094:             */
095:            public BookmarkablePageRequestTarget(String pageMapName,
096:                    Class pageClass, PageParameters pageParameters) {
097:                if (pageClass == null) {
098:                    throw new IllegalArgumentException(
099:                            "Argument pageClass must be not null");
100:                }
101:
102:                if (!Page.class.isAssignableFrom(pageClass)) {
103:                    throw new IllegalArgumentException(
104:                            "Argument pageClass must be an instance of "
105:                                    + Page.class.getName());
106:                }
107:                this .pageClass = pageClass;
108:                this .pageParameters = (pageParameters == null) ? new PageParameters()
109:                        : pageParameters;
110:                this .pageMapName = pageMapName;
111:            }
112:
113:            /**
114:             * @see wicket.IRequestTarget#detach(wicket.RequestCycle)
115:             */
116:            public void detach(RequestCycle requestCycle) {
117:                if (page != null) {
118:                    page.internalDetach();
119:                }
120:            }
121:
122:            /**
123:             * @see java.lang.Object#equals(java.lang.Object)
124:             */
125:            public boolean equals(Object obj) {
126:                boolean equal = false;
127:                if (obj != null
128:                        && (obj instanceof  BookmarkablePageRequestTarget)) {
129:                    BookmarkablePageRequestTarget that = (BookmarkablePageRequestTarget) obj;
130:                    if (pageClass.equals(that.pageClass)) {
131:                        boolean mapMatch = false;
132:
133:                        if (pageMapName != null) {
134:                            mapMatch = (that.pageMapName != null && pageMapName
135:                                    .equals(that.pageMapName));
136:                        } else {
137:                            mapMatch = (that.pageMapName == null);
138:                        }
139:
140:                        equal = mapMatch;
141:                    }
142:                }
143:                return equal;
144:            }
145:
146:            /**
147:             * @return The page that was created, null if the response did not happen
148:             *         yet
149:             */
150:            public final Page getPage() {
151:                return page;
152:            }
153:
154:            /**
155:             * @see wicket.request.target.component.IBookmarkablePageRequestTarget#getPageClass()
156:             */
157:            public final Class getPageClass() {
158:                return pageClass;
159:            }
160:
161:            /**
162:             * @see wicket.request.target.component.IBookmarkablePageRequestTarget#getPageMapName()
163:             */
164:            public final String getPageMapName() {
165:                return pageMapName;
166:            }
167:
168:            /**
169:             * @see wicket.request.target.component.IBookmarkablePageRequestTarget#getPageParameters()
170:             */
171:            public final PageParameters getPageParameters() {
172:                return pageParameters;
173:            }
174:
175:            /**
176:             * @see java.lang.Object#hashCode()
177:             */
178:            public int hashCode() {
179:                int result = "BookmarkablePageRequestTarget".hashCode();
180:                result += pageClass.hashCode();
181:                result += pageMapName != null ? pageMapName.hashCode() : 0;
182:                return 17 * result;
183:            }
184:
185:            /**
186:             * @see wicket.request.target.IEventProcessor#processEvents(wicket.RequestCycle)
187:             */
188:            public void processEvents(RequestCycle requestCycle) {
189:                if (!requestCycle.getRedirect()) {
190:                    requestCycle.setUpdateSession(true);
191:                    page = getPage(requestCycle);
192:                }
193:            }
194:
195:            /**
196:             * @see wicket.IRequestTarget#respond(wicket.RequestCycle)
197:             */
198:            public void respond(RequestCycle requestCycle) {
199:                if (pageClass != null) {
200:                    if (requestCycle.getRedirect()) {
201:                        IRequestCycleProcessor processor = requestCycle
202:                                .getProcessor();
203:                        String redirectUrl = processor
204:                                .getRequestCodingStrategy().encode(
205:                                        requestCycle, this ).toString();
206:                        requestCycle.getResponse().redirect(redirectUrl);
207:                    } else {
208:                        // Let the page render itself
209:                        getPage(requestCycle).renderPage();
210:                    }
211:                }
212:            }
213:
214:            /**
215:             * @see wicket.IRequestTarget#getLock(RequestCycle)
216:             */
217:            public Object getLock(RequestCycle requestCycle) {
218:                // we need to lock when we are not redirecting, i.e. we are
219:                // actually rendering the page
220:                return !requestCycle.getRedirect() ? requestCycle.getSession()
221:                        : null;
222:            }
223:
224:            /**
225:             * @see java.lang.Object#toString()
226:             */
227:            public String toString() {
228:                return "[BookmarkablePageRequestTarget@" + hashCode()
229:                        + " pageClass=" + pageClass.getName() + "]";
230:            }
231:
232:            /**
233:             * Constructs a new instance of a page given its class name
234:             * 
235:             * @param pageClass
236:             *            class name of the page to be created
237:             * @param requestCycle
238:             *            request cycle
239:             * @return new instance of page
240:             */
241:            protected Page newPage(final Class pageClass,
242:                    final RequestCycle requestCycle) {
243:                // Construct a new instance using the default page factory
244:                IPageFactory pageFactory = requestCycle.getApplication()
245:                        .getSessionSettings().getPageFactory();
246:
247:                if (pageParameters == null || pageParameters.size() == 0) {
248:                    return pageFactory.newPage(pageClass);
249:                } else {
250:                    return pageFactory.newPage(pageClass, pageParameters);
251:                }
252:            }
253:
254:            /**
255:             * Gets a newly constructed page if we are not in a redirect.
256:             * 
257:             * @param requestCycle
258:             *            the request cycle
259:             * @return the page
260:             */
261:            private final Page getPage(RequestCycle requestCycle) {
262:                if (page == null && pageClass != null
263:                        && !requestCycle.getRedirect()) {
264:                    page = newPage(pageClass, requestCycle);
265:                }
266:                return page;
267:            }
268:
269:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.