Source Code Cross Referenced for Base.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.util.internal.InternalStringBuilder;
022:
023:        //java imports
024:
025:        import org.apache.beehive.netui.tags.AbstractSimpleTag;
026:        import org.apache.beehive.netui.tags.IAttributeConsumer;
027:        import org.apache.beehive.netui.tags.rendering.AbstractAttributeState;
028:        import org.apache.beehive.netui.tags.rendering.BaseTag;
029:        import org.apache.beehive.netui.tags.rendering.TagRenderingBase;
030:        import org.apache.beehive.netui.tags.rendering.WriteRenderAppender;
031:        import org.apache.beehive.netui.util.Bundle;
032:
033:        import javax.servlet.http.HttpServletRequest;
034:        import javax.servlet.jsp.JspException;
035:        import javax.servlet.jsp.PageContext;
036:        import java.io.IOException;
037:
038:        /**
039:         * Provides the base for every URL on this page.
040:         * @jsptagref.tagdescription Provides the base for every URL on the page.
041:         * @example In this sample, the Base tag is simply dropped in and then automatically determines
042:         * the base for each URL on this page.
043:         * <pre>
044:         * &lt;head>
045:         *      &lt;netui:base />
046:         * &lt;/head>
047:         * </pre>
048:         * @netui:tag name="base" body-content="scriptless" description="Provides the base for every URL on this page."
049:         */
050:        public class Base extends AbstractSimpleTag implements 
051:                IAttributeConsumer, HtmlConstants {
052:            private BaseTag.State _state = new BaseTag.State();
053:
054:            /**
055:             * Returns the name of the Tag.
056:             */
057:            public String getTagName() {
058:                return "Base";
059:            }
060:
061:            /**
062:             * Set the default window target.
063:             * @param target the window target.
064:             * @jsptagref.attributedescription The default window target.
065:             * @jsptagref.databindable false
066:             * @jsptagref.attributesyntaxvalue <i>string_windowTarget</i>
067:             * @netui:attribute required="false" rtexprvalue="true"
068:             * description="The default window target."
069:             */
070:            public void setTarget(String target) {
071:                _state.target = setNonEmptyValueAttribute(target);
072:            }
073:
074:            /**
075:             * Base support for the attribute tag.  The <code>href</code> may not bet set.
076:             * @param name  The name of the attribute.  This value may not be null or the empty string.
077:             * @param value The value of the attribute.  This may contain an expression.
078:             * @param facet The name of a facet to which the attribute will be applied.  This is optional.
079:             * @throws JspException A JspException may be thrown if there is an error setting the attribute.
080:             */
081:            public void setAttribute(String name, String value, String facet)
082:                    throws JspException {
083:                boolean error = false;
084:
085:                // validate the name attribute, in the case of an error simply return.
086:                if (name == null || name.length() <= 0) {
087:                    String s = Bundle.getString("Tags_AttributeNameNotSet");
088:                    registerTagError(s, null);
089:                    error = true;
090:                }
091:                if (facet != null) {
092:                    String s = Bundle.getString(
093:                            "Tags_AttributeFacetNotSupported",
094:                            new Object[] { facet });
095:                    registerTagError(s, null);
096:                    error = true;
097:                }
098:
099:                // it's not legal to set the href attributes this way
100:                if (name != null && name.equals(HREF)) {
101:                    String s = Bundle.getString("Tags_AttributeMayNotBeSet",
102:                            new Object[] { name });
103:                    registerTagError(s, null);
104:                    error = true;
105:                }
106:                if (error)
107:                    return;
108:
109:                // set the state variables that will override the tag settings...
110:                if (name.equals(TARGET)) {
111:                    _state.target = value;
112:                    return;
113:                }
114:
115:                _state.registerAttribute(AbstractAttributeState.ATTR_GENERAL,
116:                        name, value);
117:            }
118:
119:            /**
120:             * Render the hyperlink.
121:             * @throws JspException if a JSP exception has occurred
122:             */
123:            public void doTag() throws JspException, IOException {
124:                PageContext pageContext = getPageContext();
125:                HttpServletRequest request = (HttpServletRequest) pageContext
126:                        .getRequest();
127:                TagRenderingBase br = TagRenderingBase.Factory.getRendering(
128:                        TagRenderingBase.BASE_TAG, request);
129:
130:                // evaluate the body, this is called basically so any attributes my be applied.
131:                getBufferBody(false);
132:
133:                InternalStringBuilder buf = new InternalStringBuilder(64);
134:
135:                // calculate the href
136:                buf.append(request.getScheme());
137:                buf.append("://");
138:                buf.append(request.getServerName());
139:
140:                String scheme = request.getScheme();
141:                int port = request.getServerPort();
142:                if ("http".equals(scheme) && (80 == port)) {
143:                    //Do nothing
144:                } else if ("https".equals(scheme) && (443 == port)) {
145:                    //Do nothing
146:                } else {
147:                    buf.append(":");
148:                    buf.append(request.getServerPort());
149:                }
150:                buf.append(request.getRequestURI());
151:                _state.href = buf.toString();
152:
153:                // render the tag.
154:                WriteRenderAppender writer = new WriteRenderAppender(
155:                        pageContext);
156:                br.doStartTag(writer, _state);
157:                br.doEndTag(writer);
158:
159:                // This will produce invalid HTML/XHTML if there are errors
160:                // because we are going to put markup out into the head.
161:                if (hasErrors())
162:                    reportErrors();
163:            }
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.