Source Code Cross Referenced for RewriteURL.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » netui » tags » html » 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 » Library » Apache beehive 1.0.2 src » org.apache.beehive.netui.tags.html 
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:         * $Header:$
018:         */
019:        package org.apache.beehive.netui.tags.html;
020:
021:        import org.apache.beehive.netui.core.urls.FreezableMutableURI;
022:        import org.apache.beehive.netui.core.urls.URIContext;
023:        import org.apache.beehive.netui.core.urls.URLType;
024:        import org.apache.beehive.netui.core.urls.URLRewriterService;
025:        import org.apache.beehive.netui.pageflow.PageFlowUtils;
026:        import org.apache.beehive.netui.pageflow.internal.URIContextFactory;
027:        import org.apache.beehive.netui.tags.AbstractClassicTag;
028:        import org.apache.beehive.netui.tags.rendering.TagRenderingBase;
029:        import org.apache.beehive.netui.util.Bundle;
030:        import org.apache.beehive.netui.util.ParamHelper;
031:        import org.apache.beehive.netui.util.config.ConfigUtil;
032:        import org.apache.beehive.netui.util.config.bean.UrlConfig;
033:
034:        import javax.servlet.ServletContext;
035:        import javax.servlet.http.HttpServletRequest;
036:        import javax.servlet.http.HttpServletResponse;
037:        import javax.servlet.jsp.JspException;
038:        import java.net.URISyntaxException;
039:        import java.util.HashMap;
040:        import java.util.Map;
041:
042:        /**
043:         * Allow a URL to participate in rewritting.  Some containers rewrite URLs.
044:         * This tag will pass the URL attribute through the rewriters to generate a
045:         * rewritten URL before it is output into the HTML stream.
046:         * @jsptagref.tagdescription Allows a URL to participate in URL rewritting.
047:         * Some containers rewrite URLs. This tag will pass the URL attribute through
048:         * the rewriters to generate a rewritten URL before it is output into the HTML stream.
049:         * @example In this sample, the URL attribute will be rewritten and output within
050:         * the span tags.  The actual value that will be written to the rendered HTML may
051:         * change depending on the application container.
052:         * <pre>    &lt;span>URL: &lt;netui:rewriteURL URL="foo.do"/&gt;&lt;/span></pre>
053:         * @netui:tag name="rewriteURL" description="Allows the URL Rewriter to rewrite the url attribute before it is output into the HTML stream."
054:         */
055:        public class RewriteURL extends AbstractClassicTag implements 
056:                IUrlParams {
057:            private Map _params; // Any parameters to the submit
058:            protected String url = null;
059:
060:            /**
061:             * Return the name of the Tag.
062:             */
063:            public String getTagName() {
064:                return "RewriteURL";
065:            }
066:
067:            /**
068:             * Sets the URL to be rewritten.
069:             * @param url the value of the URL that will be rewritten.
070:             * @jsptagref.attributedescription The value of the URL that will be rewritten.
071:             * @jsptagref.attributesyntaxvalue <i>string_url</i>
072:             * @netui:attribute required="true" rtexprvalue="true"
073:             * description="The value of the URL that will be rewritten."
074:             */
075:            public void setURL(String url) {
076:                this .url = url;
077:            }
078:
079:            /**
080:             * This method will allow a tag that produces one or more Urls to have parameters set
081:             * on the tag.  The name and value should be required.  The facet is optional, and
082:             * allows tags producing more than one URL to have parameters set on different URLs.
083:             *
084:             * @param name  The name of the parameter to be added to the URL.
085:             * @param value The value of the parameter.
086:             * @param facet The name of a facet for which the parameter should be added.
087:             * @throws javax.servlet.jsp.JspException
088:             */
089:            public void addParameter(String name, Object value, String facet)
090:                    throws JspException {
091:                if (_params == null) {
092:                    _params = new HashMap();
093:                }
094:                ParamHelper.addParam(_params, name, value);
095:            }
096:
097:            /**
098:             * Render the beginning of the rewriteURL tag.
099:             * @throws JspException if a JSP exception has occurred
100:             */
101:            public int doStartTag() throws JspException {
102:                // Evaluate the body of this tag
103:                return EVAL_BODY_BUFFERED;
104:            }
105:
106:            /**
107:             * Render the end of the rewriteURL tag.
108:             * @throws JspException if a JSP exception has occurred
109:             */
110:            public int doEndTag() throws JspException {
111:                HttpServletRequest request = (HttpServletRequest) pageContext
112:                        .getRequest();
113:                HttpServletResponse response = (HttpServletResponse) pageContext
114:                        .getResponse();
115:                ServletContext context = pageContext.getServletContext();
116:
117:                try {
118:                    boolean encoded = false;
119:                    UrlConfig urlConfig = ConfigUtil.getConfig().getUrlConfig();
120:                    if (urlConfig != null) {
121:                        encoded = !urlConfig.isUrlEncodeUrls();
122:                    }
123:
124:                    FreezableMutableURI uri = new FreezableMutableURI();
125:                    uri.setEncoding(response.getCharacterEncoding());
126:                    uri.setURI(url, encoded);
127:                    boolean needsToBeSecure = false;
128:                    if (_params != null) {
129:                        uri.addParameters(_params, false);
130:                    }
131:                    if (!uri.isAbsolute()
132:                            && PageFlowUtils.needsToBeSecure(context, request,
133:                                    url, true)) {
134:                        needsToBeSecure = true;
135:                    }
136:
137:                    URLRewriterService.rewriteURL(context, request, response,
138:                            uri, URLType.ACTION, needsToBeSecure);
139:                    String key = PageFlowUtils.getURLTemplateKey(
140:                            URLType.ACTION, needsToBeSecure);
141:                    boolean forXML = TagRenderingBase.Factory.isXHTML(request);
142:                    URIContext uriContext = URIContextFactory
143:                            .getInstance(forXML);
144:                    String uriString = URLRewriterService.getTemplatedURL(
145:                            context, request, uri, key, uriContext);
146:                    write(response.encodeURL(uriString));
147:                } catch (URISyntaxException e) {
148:                    // report the error...
149:                    String s = Bundle.getString("Tags_RewriteURL_URLException",
150:                            new Object[] { url, e.getMessage() });
151:                    registerTagError(s, e);
152:                    reportErrors();
153:                }
154:
155:                localRelease();
156:                return EVAL_PAGE;
157:            }
158:
159:            /**
160:             * Release any acquired resources.
161:             */
162:            protected void localRelease() {
163:                super.localRelease();
164:                _params = null;
165:                url = null;
166:            }
167:
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.