Source Code Cross Referenced for HtmlImageInput.java in  » Testing » htmlunit » com » gargoylesoftware » htmlunit » 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 » Testing » htmlunit » com.gargoylesoftware.htmlunit.html 
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.html;
039:
040:        import java.io.IOException;
041:        import java.util.Map;
042:
043:        import org.apache.commons.lang.StringUtils;
044:
045:        import com.gargoylesoftware.htmlunit.ElementNotFoundException;
046:        import com.gargoylesoftware.htmlunit.KeyValuePair;
047:        import com.gargoylesoftware.htmlunit.Page;
048:
049:        /**
050:         *  Wrapper for the html element "input"
051:         *
052:         * @version $Revision: 2132 $
053:         * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
054:         * @author David K. Taylor
055:         * @author <a href="mailto:cse@dynabean.de">Christian Sell</a>
056:         * @author Marc Guillemot
057:         * @author Daniel Gredler
058:         * @author Ahmed Ashour
059:         */
060:        public class HtmlImageInput extends HtmlInput {
061:
062:            private static final long serialVersionUID = -2955826367201282767L;
063:
064:            // For click with x, y position.
065:            private boolean wasPositionSpecified_;
066:            private int xPosition_;
067:            private int yPosition_;
068:
069:            /**
070:             * Create an instance
071:             *
072:             * @param page The page that contains this element
073:             * @param attributes the initial attributes
074:             * @deprecated You should not directly construct HtmlImageInput.
075:             */
076:            //TODO: to be removed, deprecated after 1.11
077:            public HtmlImageInput(final HtmlPage page, final Map attributes) {
078:                this (null, TAG_NAME, page, attributes);
079:            }
080:
081:            /**
082:             * Create an instance
083:             *
084:             * @param namespaceURI the URI that identifies an XML namespace.
085:             * @param qualifiedName The qualified name of the element type to instantiate
086:             * @param page The page that contains this element
087:             * @param attributes the initial attributes
088:             */
089:            HtmlImageInput(final String namespaceURI,
090:                    final String qualifiedName, final HtmlPage page,
091:                    final Map attributes) {
092:                super (namespaceURI, qualifiedName, page, attributes);
093:            }
094:
095:            /**
096:             * Return an array of KeyValuePairs that are the values that will be sent
097:             * back to the server whenever the current form is submitted.<p>
098:             *
099:             * THIS METHOD IS INTENDED FOR THE USE OF THE FRAMEWORK ONLY AND SHOULD NOT
100:             * BE USED BY CONSUMERS OF HTMLUNIT. USE AT YOUR OWN RISK.
101:             *
102:             * @return See above
103:             */
104:            public KeyValuePair[] getSubmitKeyValuePairs() {
105:                final String name = getNameAttribute();
106:                final String prefix;
107:                // a clicked image without name sends parameter x and y
108:                if (StringUtils.isEmpty(name)) {
109:                    prefix = "";
110:                } else {
111:                    prefix = name + ".";
112:                }
113:
114:                if (wasPositionSpecified_) {
115:                    return new KeyValuePair[] {
116:                            new KeyValuePair(prefix + 'x', String
117:                                    .valueOf(xPosition_)),
118:                            new KeyValuePair(prefix + 'y', String
119:                                    .valueOf(yPosition_)) };
120:                }
121:                return new KeyValuePair[] { new KeyValuePair(
122:                        getNameAttribute(), getValueAttribute()) };
123:            }
124:
125:            /**
126:             * Submit the form that contains this input.  Only a couple of the inputs
127:             * support this method so it is made protected here.  Those subclasses
128:             * that wish to expose it will override and make it public.
129:             *
130:             * @return The Page that is the result of submitting this page to the server
131:             * @exception IOException If an io error occurs
132:             */
133:            public Page click() throws IOException {
134:                return click(0, 0);
135:            }
136:
137:            /**
138:             * This method will be called if there either wasn't an onclick handler or there was
139:             * but the result of that handler was true.  This is the default behavior of clicking
140:             * the element.  The default implementation returns the current page - subclasses
141:             * requiring different behavior (like {@link HtmlSubmitInput}) will override this
142:             * method.
143:             *
144:             * @param defaultPage The default page to return if the action does not
145:             * load a new page.
146:             * @return The page that is currently loaded after execution of this method
147:             * @throws IOException If an IO error occurred
148:             */
149:            protected Page doClickAction(final Page defaultPage)
150:                    throws IOException {
151:                final HtmlForm form = getEnclosingForm();
152:                if (form != null) {
153:                    return form.submit(this );
154:                } else {
155:                    return super .doClickAction(defaultPage);
156:                }
157:            }
158:
159:            /**
160:             * Simulate clicking this input with a pointing device.  The x and y coordinates
161:             * of the pointing device will be sent to the server.
162:             *
163:             * @param x The x coordinate of the pointing device at the time of clicking
164:             * @param y The y coordinate of the pointing device at the time of clicking
165:             * @return The page that is loaded after the click has taken place.
166:             * @exception IOException If an io error occurs
167:             * @exception ElementNotFoundException If a particular xml element could not be found in the dom model
168:             */
169:            public Page click(final int x, final int y) throws IOException,
170:                    ElementNotFoundException {
171:
172:                wasPositionSpecified_ = true;
173:                xPosition_ = x;
174:                yPosition_ = y;
175:                return super .click();
176:            }
177:
178:            /**
179:             * {@inheritDoc} Also sets the value to the new default value, just like IE.
180:             * @see SubmittableElement#setDefaultValue(String)
181:             */
182:            public void setDefaultValue(final String defaultValue) {
183:                super.setDefaultValue(defaultValue);
184:                setValueAttribute(defaultValue);
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.