1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.jameleon.plugin.htmlunit.tags;
20
21 import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
22 import com.gargoylesoftware.htmlunit.html.HtmlInput;
23
24 /***
25 * This tag is used to set or unset checkboxes defined by a given XPath expression.
26 *
27 * <p>
28 * To use XPath to check a checkbox named <b>cb_1</b> that exists in a form with the name <b>testform</b>:<br/>
29 * <pre><source>
30 * <htmlunit-set-checkbox
31 * functionId="Check the checkbox named cb_1 field"
32 * xpath="//form[@name='testform']/input[@name='cb_1']"
33 * checked="true"/>
34 * </source></pre>
35 * </p>
36 * <p>
37 * To use XPath to uncheck a checkbox named <b>cb_1</b> that exists in a form with the name <b>testform</b>:
38 * <pre><source>
39 * <htmlunit-set-checkbox
40 * functionId="Uncheck the checkbox named cb_1 field"
41 * xpath="//form[@name='testform']/input[@name='cb_1']"
42 * checked="false"/>
43 * </source></pre>
44 * </p>
45 * <p>
46 * To use the form and the field name to check a checkbox named <b>cb_1</b> that exists in a form with the name <b>testform</b>:
47 * <pre><source>
48 * <htmlunit-set-checkbox
49 * functionId="Check the checkbox named cb_1 field"
50 * form="testform"
51 * fieldName="cb_1"
52 * checked="true"/>
53 * </source></pre>
54 * </p>
55 * @jameleon.function name="htmlunit-set-checkbox" type="action"
56 */
57 public class HtmlUnitSetCheckBoxTag extends AbstractHtmlUnitCheckFieldTag{
58
59
60 protected void checkFieldWithValue(String fieldName, String value, boolean check){
61 setCheckBox(fieldName, value, check);
62 }
63
64 protected void checkField(HtmlInput inputField, boolean check){
65 ((HtmlCheckBoxInput)inputField).setChecked(check);
66 }
67
68 protected void checkFieldWithNoValue(String fieldName, boolean check){
69 setCheckBox(fieldName, checked.booleanValue());
70 }
71
72 protected String getInputType(){
73 return "checkbox";
74 }
75
76 }