Source Code Cross Referenced for Field.java in  » IDE-Netbeans » visualweb.api.designer » com » sun » rave » web » ui » 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 » IDE Netbeans » visualweb.api.designer » com.sun.rave.web.ui.component 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package com.sun.rave.web.ui.component;
042:
043:        import com.sun.rave.web.ui.util.ComponentUtilities;
044:        import java.beans.Beans;
045:        import javax.faces.component.UIComponent;
046:        import javax.faces.component.UIOutput;
047:        import javax.faces.context.FacesContext;
048:
049:        /**
050:         *
051:         * @author avk
052:         */
053:        public class Field extends FieldBase implements  ComplexComponent {
054:
055:            public static final String READONLY_ID = "_readOnly"; //NOI18N
056:            public static final String LABEL_ID = "_label"; //NOI18N
057:            public static final String INPUT_ID = "_field"; //NOI18N
058:            public static final String READONLY_FACET = "readOnly"; //NOI18N
059:            public static final String LABEL_FACET = "label";
060:
061:            private static final boolean DEBUG = false;
062:
063:            /** Creates a new instance of FieldBase */
064:            public Field() {
065:            }
066:
067:            // Labels
068:            public UIComponent getLabelComponent(FacesContext context,
069:                    String style) {
070:
071:                if (DEBUG)
072:                    log("getReadOnlyComponent()");
073:
074:                // Check if the page author has defined a label facet
075:                UIComponent labelComponent = getFacet(LABEL_FACET); //NOI18N
076:
077:                // If the page author has not defined a label facet,
078:                // check if the page author specified a label.
079:                if (labelComponent == null) {
080:                    String label = getLabel();
081:                    if (label != null && label.length() > 0) {
082:                        labelComponent = createLabel(label, style, context); //NOI18N\
083:                    }
084:                } else if (DEBUG) {
085:                    log("\tFound facet."); //NOI18N
086:                }
087:
088:                return labelComponent;
089:            }
090:
091:            // Readonly value
092:            public UIComponent getReadOnlyComponent(FacesContext context) {
093:
094:                if (DEBUG)
095:                    log("getListLabelComponent()");
096:
097:                String id = getId();
098:
099:                // Check if the page author has defined a label facet
100:                UIComponent textComponent = getFacet(READONLY_FACET); //NOI18N
101:
102:                // If the page author has not defined a label facet,
103:                // check if the page author specified a label.
104:                if (textComponent == null) {
105:                    textComponent = createText(getReadOnlyValueString(context)); //NOI18N
106:                    //<RAVE>
107:                } else {
108:                    if (DEBUG) {
109:                        log("\tFound facet."); //NOI18N
110:                    }
111:                    //CR 6391493
112:                    //The readonly component was cached. Make sure its value (text) property is up to date.
113:                    if (textComponent instanceof  UIOutput) {
114:                        UIOutput outputComponent = (UIOutput) textComponent;
115:                        outputComponent
116:                                .setValue(getReadOnlyValueString(context));
117:                    }
118:                    //</RAVE>
119:                }
120:
121:                return textComponent;
122:            }
123:
124:            private UIComponent createLabel(String labelString, String style,
125:                    FacesContext context) {
126:
127:                if (DEBUG)
128:                    log("createLabel()");
129:
130:                // If we find a label, define a component and add it to the
131:                // children, unless it has been added in a previous cycle
132:                // (the component is being redisplayed).
133:
134:                if (labelString == null || labelString.length() < 1) {
135:                    if (DEBUG)
136:                        log("\tNo label");
137:                    return null;
138:                } else if (DEBUG) {
139:                    log("\tLabel is " + labelString); //NOI18N
140:                }
141:
142:                Label label = new Label();
143:                label.setId(getId().concat(LABEL_ID));
144:                label.setLabelLevel(getLabelLevel());
145:                label.setStyleClass(style);
146:                label.setText(labelString);
147:                label.setLabeledComponent(this );
148:                // <RAVE>
149:                // this.getFacets().put(LABEL_FACET, label);
150:                if (!Beans.isDesignTime())
151:                    this .getFacets().put(LABEL_FACET, label);
152:                // </RAVE>
153:                return label;
154:            }
155:
156:            private UIComponent createText(String string) {
157:
158:                if (DEBUG)
159:                    log("createText()");
160:
161:                // If we find a label, define a component and add it to the
162:                // children, unless it has been added in a previous cycle
163:                // (the component is being redisplayed).
164:
165:                if (string == null || string.length() < 1) {
166:                    // TODO - maybe print a default?
167:                    string = new String();
168:                }
169:                StaticText text = new StaticText();
170:                text.setText(string);
171:                text.setId(getId().concat(READONLY_ID));
172:                // <RAVE>
173:                // this.getFacets().put(READONLY_FACET, text);
174:                if (!Beans.isDesignTime())
175:                    this .getFacets().put(READONLY_FACET, text);
176:                // </RAVE>
177:                return text;
178:            }
179:
180:            /**
181:             * Log an error - only used during development time.
182:             */
183:            protected void log(String s) {
184:                System.out.println(this .getClass().getName() + "::" + s); //NOI18N
185:            }
186:
187:            // <RAVE>
188:            // Merged INF http://inf.central/inf/integrationReport.jsp?id=82661 from braveheart.
189:            // It fixes bug 6349156: File upload label's "for" attribute value is incorrect
190:
191:            /** 
192:             * Retrieves the DOM ID for the HTML input element. To be used by 
193:             * Label component as a value for the "for" attribute. 
194:             */
195:            public String getPrimaryElementID(FacesContext context) {
196:
197:                // Check for a public facet
198:                String clntId = this .getClientId(context);
199:                UIComponent facet = getFacet(LABEL_FACET);
200:                if (facet != null) {
201:                    return clntId.concat(this .INPUT_ID);
202:                }
203:                // Need to check for the private facet as well. Note that 
204:                // this is not ideal - unless getLabelComponent has been invoked
205:                // first, the private facet will be null. (Is there a reason 
206:                // we can't just invoke getLabelComponent instead of getFacet?). 
207:
208:                // Pass "false" since we don't want to get null if the id's 
209:                // don't match. We don't care at this point, in fact they
210:                // should match because getLabelComponent must have been
211:                // called in order for this to even work.
212:                //
213:                facet = ComponentUtilities.getPrivateFacet(this , LABEL_FACET,
214:                        false);
215:                if (facet == null) {
216:                    return getClientId(context);
217:                }
218:                return this .getClientId(context).concat(this .INPUT_ID);
219:            }
220:
221:            // <RAVE>
222:
223:            public int getColumns() {
224:
225:                int columns = super .getColumns();
226:                if (columns < 1) {
227:                    columns = 20;
228:                    super .setColumns(20);
229:                }
230:                return columns;
231:            }
232:
233:            // <RAVE>
234:            public void setText(Object text) {
235:                if (this .isReadOnly()) {
236:                    UIComponent facet = (UIComponent) getFacets().get(
237:                            READONLY_FACET);
238:                    if (facet == null || !(facet instanceof  StaticText)) {
239:                        StaticText staticText = new StaticText();
240:                        staticText.setId(getId().concat(READONLY_ID));
241:                        getFacets().put(READONLY_FACET, staticText);
242:                        facet = staticText;
243:                    }
244:                    ((StaticText) facet).setText(text);
245:                }
246:                super .setText(text);
247:            }
248:            // </RAVE>
249:
250:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.