Source Code Cross Referenced for HTMLInputElement.java in  » Testing » htmlunit » com » gargoylesoftware » htmlunit » javascript » host » 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 » Testing » htmlunit » com.gargoylesoftware.htmlunit.javascript.host 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2002-2008 Gargoyle Software Inc. All rights reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         * 1. Redistributions of source code must retain the above copyright notice,
008:         *    this list of conditions and the following disclaimer.
009:         * 2. Redistributions in binary form must reproduce the above copyright notice,
010:         *    this list of conditions and the following disclaimer in the documentation
011:         *    and/or other materials provided with the distribution.
012:         * 3. The end-user documentation included with the redistribution, if any, must
013:         *    include the following acknowledgment:
014:         *
015:         *       "This product includes software developed by Gargoyle Software Inc.
016:         *        (http://www.GargoyleSoftware.com/)."
017:         *
018:         *    Alternately, this acknowledgment may appear in the software itself, if
019:         *    and wherever such third-party acknowledgments normally appear.
020:         * 4. The name "Gargoyle Software" must not be used to endorse or promote
021:         *    products derived from this software without prior written permission.
022:         *    For written permission, please contact info@GargoyleSoftware.com.
023:         * 5. Products derived from this software may not be called "HtmlUnit", nor may
024:         *    "HtmlUnit" appear in their name, without prior written permission of
025:         *    Gargoyle Software Inc.
026:         *
027:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
028:         * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
029:         * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARGOYLE
030:         * SOFTWARE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
031:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
032:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
033:         * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
034:         * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
035:         * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
036:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
037:         */
038:        package com.gargoylesoftware.htmlunit.javascript.host;
039:
040:        import org.xml.sax.helpers.AttributesImpl;
041:
042:        import com.gargoylesoftware.htmlunit.html.HtmlInput;
043:        import com.gargoylesoftware.htmlunit.html.InputElementFactory;
044:
045:        /**
046:         * The javascript object for form input elements (html tag <input ...>).
047:         *
048:         * @version $Revision: 2132 $
049:         * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
050:         * @author <a href="mailto:cse@dynabean.de">Christian Sell</a>
051:         * @author Marc Guillemot
052:         * @author Chris Erskine
053:         * @author Ahmed Ashour
054:         */
055:        public class HTMLInputElement extends FormField {
056:
057:            private static final long serialVersionUID = 3712016051364495710L;
058:
059:            /**
060:             * Create an instance.
061:             */
062:            public HTMLInputElement() {
063:            }
064:
065:            /**
066:             * Javascript constructor. This must be declared in every javascript file
067:             * because the rhino engine won't walk up the hierarchy looking for constructors.
068:             */
069:            public void jsConstructor() {
070:            }
071:
072:            /**
073:             * Sets the value of the attribute "type".
074:             * Note: this replace the DOM node with a new one.
075:             * @param newType the new type to set
076:             */
077:            public void jsxSet_type(final String newType) {
078:                HtmlInput input = getHtmlInputOrDie();
079:
080:                if (!input.getTypeAttribute().equalsIgnoreCase(newType)) {
081:                    final AttributesImpl attributes = readAttributes(input);
082:                    final int index = attributes.getIndex("type");
083:                    attributes.setValue(index, newType);
084:
085:                    final HtmlInput newInput = (HtmlInput) InputElementFactory.instance
086:                            .createElement(input.getPage(), "input", attributes);
087:
088:                    // Added check to make sure there is a previous sibling before trying to replace
089:                    // newly created input variable which has yet to be inserted into DOM tree
090:                    if (input.getPreviousDomSibling() != null) {
091:                        // if the input has a previous sibling, then it was already in the
092:                        // DOM tree and can be replaced
093:                        input.replace(newInput);
094:                    } else {
095:                        // the input hasn't yet been inserted into the DOM tree (likely has been
096:                        // created via document.createElement()), so simply replace it with the
097:                        // new Input instance created in the code above
098:                        input = newInput;
099:                    }
100:
101:                    input.setScriptObject(null);
102:                    setDomNode(newInput, true);
103:                }
104:            }
105:
106:            /**
107:             * Set the checked property. Although this property is defined in Input it
108:             * doesn't make any sense for input's other than checkbox and radio. This
109:             * implementation does nothing. The implementations in Checkbox and Radio
110:             * actually do the work.
111:             *
112:             * @param checked  True if this input should have the "checked" attribute set
113:             */
114:            public void jsxSet_checked(final boolean checked) {
115:                ((HtmlInput) getDomNodeOrDie()).setChecked(checked);
116:            }
117:
118:            /**
119:             * Commodity for <code>(HtmlInput) getHtmlElementOrDie()</code>
120:             * @return the bound html input
121:             */
122:            protected HtmlInput getHtmlInputOrDie() {
123:                return (HtmlInput) getHtmlElementOrDie();
124:            }
125:
126:            /**
127:             * Return the value of the checked property. Although this property is
128:             * defined in Input it doesn't make any sense for input's other than
129:             * checkbox and radio. This implementation does nothing. The
130:             * implementations in Checkbox and Radio actually do the work.
131:             *
132:             *@return The checked property.
133:             */
134:            public boolean jsxGet_checked() {
135:                return ((HtmlInput) getDomNodeOrDie()).isChecked();
136:            }
137:
138:            /**
139:             * Uses {@link #jsxSet_type(String)} if attribute's name is type to
140:             * replace DOM node as well as long as we have subclasses of {@link HtmlInput}.
141:             * {@inheritDoc}
142:             */
143:            public void jsxFunction_setAttribute(final String name,
144:                    final String value) {
145:                if ("type".equals(name)) {
146:                    jsxSet_type(value);
147:                } else {
148:                    super .jsxFunction_setAttribute(name, value);
149:                }
150:            }
151:
152:            /**
153:             * Returns the input's default value, used if the containing form gets reset.
154:             * @return The input's default value, used if the containing form gets reset.
155:             * @see <a href="http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/defaultvalue.asp">
156:             * MSDN Documentation</a>
157:             */
158:            public String jsxGet_defaultValue() {
159:                return ((HtmlInput) getDomNodeOrDie()).getDefaultValue();
160:            }
161:
162:            /**
163:             * Sets the input's default value, used if the containing form gets reset.
164:             * @param defaultValue The input's default value, used if the containing form gets reset.
165:             * @see <a href="http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/defaultvalue.asp">
166:             * MSDN Documentation</a>
167:             */
168:            public void jsxSet_defaultValue(final String defaultValue) {
169:                ((HtmlInput) getDomNodeOrDie()).setDefaultValue(defaultValue);
170:            }
171:
172:            /**
173:             * Returns the input's default checked value, used if the containing form gets reset.
174:             * @return The input's default checked value, used if the containing form gets reset.
175:             * @see <a href="http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/defaultchecked.asp">
176:             * MSDN Documentation</a>
177:             */
178:            public boolean jsxGet_defaultChecked() {
179:                return ((HtmlInput) getDomNodeOrDie()).isDefaultChecked();
180:            }
181:
182:            /**
183:             * Sets the input's default checked value, used if the containing form gets reset.
184:             * @param defaultChecked The input's default checked value, used if the containing form gets reset.
185:             * @see <a href="http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/defaultchecked.asp">
186:             * MSDN Documentation</a>
187:             */
188:            public void jsxSet_defaultChecked(final boolean defaultChecked) {
189:                ((HtmlInput) getDomNodeOrDie())
190:                        .setDefaultChecked(defaultChecked);
191:            }
192:
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.