Source Code Cross Referenced for IndexedParamUrlCodingStrategy.java in  » J2EE » wicket » org » apache » wicket » request » target » coding » 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.request.target.coding 
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.request.target.coding;
018:
019:        import java.util.Map;
020:
021:        import org.apache.wicket.PageMap;
022:        import org.apache.wicket.PageParameters;
023:        import org.apache.wicket.WicketRuntimeException;
024:        import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
025:        import org.apache.wicket.util.string.AppendingStringBuffer;
026:        import org.apache.wicket.util.value.ValueMap;
027:
028:        /**
029:         * Url coding strategy for bookmarkable pages that encodes index based
030:         * parameters.
031:         * 
032:         * Strategy looks for parameters whose name is an integer in an incremented
033:         * order starting with zero. Found parameters will be appended to the url in the
034:         * form /mount-path/paramvalue0/paramvalue1/paramvalue2
035:         * 
036:         * When decoded these parameters will once again be available under their index (
037:         * PageParameters.getString("0"); )
038:         * 
039:         * @author Igor Vaynberg (ivaynberg)
040:         */
041:        public class IndexedParamUrlCodingStrategy extends
042:                BookmarkablePageRequestTargetUrlCodingStrategy {
043:            /**
044:             * Construct.
045:             * 
046:             * @param mountPath
047:             *            mount path
048:             * @param bookmarkablePageClass
049:             *            class of mounted page
050:             */
051:            public IndexedParamUrlCodingStrategy(String mountPath,
052:                    Class bookmarkablePageClass) {
053:                super (mountPath, bookmarkablePageClass, PageMap.DEFAULT_NAME);
054:            }
055:
056:            /**
057:             * Construct.
058:             * 
059:             * @param mountPath
060:             *            mount path
061:             * @param bookmarkablePageClass
062:             *            class of mounted page
063:             * @param pageMapName
064:             *            name of pagemap
065:             */
066:            public IndexedParamUrlCodingStrategy(String mountPath,
067:                    Class bookmarkablePageClass, String pageMapName) {
068:                super (mountPath, bookmarkablePageClass, pageMapName);
069:            }
070:
071:            protected void appendParameters(AppendingStringBuffer url,
072:                    Map parameters) {
073:                int i = 0;
074:                while (parameters.containsKey(String.valueOf(i))) {
075:                    String value = (String) parameters.get(String.valueOf(i));
076:                    if (!url.endsWith("/")) {
077:                        url.append("/");
078:                    }
079:                    url.append(urlEncode(value)).append("/");
080:                    i++;
081:                }
082:
083:                String pageMap = (String) parameters
084:                        .get(WebRequestCodingStrategy.PAGEMAP);
085:                if (pageMap != null) {
086:                    i++;
087:                    pageMap = WebRequestCodingStrategy
088:                            .encodePageMapName(pageMap);
089:                    if (!url.endsWith("/")) {
090:                        url.append("/");
091:                    }
092:                    url.append(WebRequestCodingStrategy.PAGEMAP).append("/")
093:                            .append(urlEncode(pageMap)).append("/");
094:                }
095:
096:                if (i != parameters.size()) {
097:                    throw new WicketRuntimeException(
098:                            "Not all parameters were encoded. Make sure all parameter names are integers in consecutive order starting with zero. Current parameter names are: "
099:                                    + parameters.keySet().toString());
100:                }
101:            }
102:
103:            protected ValueMap decodeParameters(String urlFragment,
104:                    Map urlParameters) {
105:                PageParameters params = new PageParameters();
106:                if (urlFragment == null) {
107:                    return params;
108:                }
109:                if (urlFragment.startsWith("/")) {
110:                    urlFragment = urlFragment.substring(1);
111:                }
112:                if (urlFragment.length() > 0 && urlFragment.endsWith("/")) {
113:                    urlFragment = urlFragment.substring(0,
114:                            urlFragment.length() - 1);
115:                }
116:
117:                String[] parts = urlFragment.split("/");
118:                for (int i = 0; i < parts.length; i++) {
119:                    if (WebRequestCodingStrategy.PAGEMAP.equals(parts[i])) {
120:                        i++;
121:                        params
122:                                .put(
123:                                        WebRequestCodingStrategy.PAGEMAP,
124:                                        WebRequestCodingStrategy
125:                                                .decodePageMapName(urlDecode(parts[i])));
126:                    } else {
127:                        params.put(String.valueOf(i), urlDecode(parts[i]));
128:                    }
129:                }
130:                return params;
131:            }
132:
133:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.