Source Code Cross Referenced for HtmlRenderer.java in  » J2EE » myfaces-core-1.2.0 » org » apache » myfaces » shared_impl » renderkit » 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 » J2EE » myfaces core 1.2.0 » org.apache.myfaces.shared_impl.renderkit.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 The Apache Software Foundation.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.apache.myfaces.shared_impl.renderkit.html;
017:
018:        import org.apache.myfaces.shared_impl.renderkit.JSFAttr;
019:
020:        import javax.faces.application.ViewHandler;
021:        import javax.faces.component.UIComponent;
022:        import javax.faces.component.UIViewRoot;
023:        import javax.faces.context.FacesContext;
024:        import javax.faces.render.Renderer;
025:        import java.io.IOException;
026:        import java.util.List;
027:
028:        /**
029:         * @author Manfred Geiler (latest modification by $Author: baranda $)
030:         * @version $Revision: 544646 $ $Date: 2007-06-05 23:51:27 +0200 (Di, 05 Jun 2007) $
031:         */
032:        public abstract class HtmlRenderer extends Renderer {
033:
034:            /**
035:             * Return the list of children of the specified component.
036:             * <p>
037:             * This default implementation simply returns component.getChildren().
038:             * However this method should always be used in order to allow
039:             * renderer subclasses to override it and provide filtered or
040:             * reordered views of the component children to rendering
041:             * methods defined in their ancestor classes.
042:             * <p>
043:             * Any method that overrides this to "hide" child components
044:             * should also override the getChildCount method.
045:             * 
046:             * @return a list of UIComponent objects.
047:             */
048:            public List getChildren(UIComponent component) {
049:                return component.getChildren();
050:            }
051:
052:            /**
053:             * Return the number of children of the specified component.
054:             * <p>
055:             * See {@link #getChildren(UIComponent)} for more information.
056:             */
057:            public int getChildCount(UIComponent component) {
058:                return component.getChildCount();
059:            }
060:
061:            /**
062:             * @param facesContext
063:             * @return String A String representing the action URL
064:             */
065:            protected String getActionUrl(FacesContext facesContext) {
066:                ViewHandler viewHandler = facesContext.getApplication()
067:                        .getViewHandler();
068:                String viewId = facesContext.getViewRoot().getViewId();
069:                return viewHandler.getActionURL(facesContext, viewId);
070:            }
071:
072:            /**
073:             * Renders the client ID as an "id".
074:             */
075:            protected void renderId(FacesContext context, UIComponent component)
076:                    throws IOException {
077:                if (shouldRenderId(context, component)) {
078:                    String clientId = getClientId(context, component);
079:                    context.getResponseWriter().writeAttribute(HTML.ID_ATTR,
080:                            clientId, JSFAttr.ID_ATTR);
081:                }
082:            }
083:
084:            /**
085:             * Returns the client ID that should be used for rendering (if
086:             * {@link #shouldRenderId} returns true).
087:             */
088:            protected String getClientId(FacesContext context,
089:                    UIComponent component) {
090:                return component.getClientId(context);
091:            }
092:
093:            /**
094:             * Returns true if the component should render an ID.  Components
095:             * that deliver events should always return "true".
096:             * @todo Is this a bottleneck?  If so, optimize!
097:             */
098:            protected boolean shouldRenderId(FacesContext context,
099:                    UIComponent component) {
100:                String id = component.getId();
101:
102:                // Otherwise, if ID isn't set, don't bother
103:                if (id == null)
104:                    return false;
105:
106:                // ... or if the ID was generated, don't bother
107:                if (id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
108:                    return false;
109:
110:                return true;
111:            }
112:
113:            /**
114:             * Coerces an object into a URI, accounting for JSF rules
115:             * with initial slashes.
116:             */
117:            static public String toUri(Object o) {
118:                if (o == null)
119:                    return null;
120:
121:                String uri = o.toString();
122:                if (uri.startsWith("/")) {
123:                    // Treat two slashes as server-relative
124:                    if (uri.startsWith("//")) {
125:                        uri = uri.substring(1);
126:                    } else {
127:                        FacesContext fContext = FacesContext
128:                                .getCurrentInstance();
129:                        uri = fContext.getExternalContext()
130:                                .getRequestContextPath()
131:                                + uri;
132:                    }
133:                }
134:
135:                return uri;
136:            }
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.