1 /*
2 * Copyright (c) 2002-2025 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.htmlunit.html;
16
17 import org.htmlunit.util.NameValuePair;
18
19 /**
20 * An element that can have it's values sent to the server during a form submit.
21 *
22 * @author Mike Bowler
23 * @author Daniel Gredler
24 */
25 public interface SubmittableElement {
26
27 /**
28 * <p>Returns an array of {@link NameValuePair}s that are the values that will be sent
29 * back to the server whenever this element's containing form is submitted.</p>
30 *
31 * <p>THIS METHOD IS INTENDED FOR THE USE OF THE FRAMEWORK ONLY AND SHOULD NOT
32 * BE USED BY CONSUMERS OF HTMLUNIT. USE AT YOUR OWN RISK.</p>
33 *
34 * @return the values that will be sent back to the server whenever this element's
35 * containing form is submitted
36 */
37 NameValuePair[] getSubmitNameValuePairs();
38
39 /**
40 * Returns the value of this element to the default value or checked state (usually what it was at
41 * the time the page was loaded, unless it has been modified via JavaScript).
42 */
43 void reset();
44
45 /**
46 * Sets the default value to use when this element gets reset, if applicable.
47 * @param defaultValue the default value to use when this element gets reset, if applicable
48 */
49 void setDefaultValue(String defaultValue);
50
51 /**
52 * Returns the default value to use when this element gets reset, if applicable.
53 * @return the default value to use when this element gets reset, if applicable
54 */
55 String getDefaultValue();
56
57 /**
58 * Sets the default checked state to use when this element gets reset, if applicable.
59 * The default implementation is empty; only checkboxes and radio buttons
60 * really care what the default checked value is.
61 * @see SubmittableElement#setDefaultChecked(boolean)
62 * @see HtmlRadioButtonInput#setDefaultChecked(boolean)
63 * @see HtmlCheckBoxInput#setDefaultChecked(boolean)
64 *
65 * @param defaultChecked the default checked state to use when this element gets reset, if applicable
66 */
67 void setDefaultChecked(boolean defaultChecked);
68
69 /**
70 * Returns the default checked state to use when this element gets reset, if applicable.
71 * @return the default checked state to use when this element gets reset, if applicable
72 */
73 boolean isDefaultChecked();
74
75 }