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.HtmlInput;
22 import com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput;
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 radio button named <b>rb_1</b> that exists in a form with the name <b>testform</b>:<br/>
29 * <pre><source>
30 * <htmlunit-set-radio-button
31 * functionId="Check the radio button named rb_1"
32 * xpath="//form[@name='testform']/input[@name='rb_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-radio-button
40 * functionId="Uncheck the radio button named rb_1"
41 * xpath="//form[@name='testform']/input[@name='rb_1']"
42 * checked="false"/>
43 * </source></pre>
44 * </p>
45 * <p>
46 * To use the form and the field name to check a radio button named <b>rb_1</b> that exists in a form with the name <b>testform</b>:
47 * <pre><source>
48 * <htmlunit-set-radio-button
49 * functionId="Check the radio button named rb_1"
50 * form="testform"
51 * fieldName="rb_1"
52 * checked="true"/>
53 * </source></pre>
54 * </p>
55 * <p>
56 * To use the form, field name and value to check a radio button named <b>rb_1</b> with the value
57 * <b>rb_val1</b> that exists in a form with the name <b>testform</b>:
58 * <pre><source>
59 * <htmlunit-set-radio-button
60 * functionId="Check the radio button named rb_1"
61 * form="testform"
62 * fieldName="rb_1"
63 * value="rb_val1"
64 * checked="true"/>
65 * </source></pre>
66 * </p>
67 * @jameleon.function name="htmlunit-set-radio-button" type="action"
68 */
69 public class HtmlUnitSetRadioButtonTag extends AbstractHtmlUnitCheckFieldTag{
70
71 protected void checkFieldWithValue(String fieldName, String value, boolean check){
72 setRadioButton(fieldName, value, check);
73 }
74
75 protected void checkField(HtmlInput inputField, boolean check){
76 ((HtmlRadioButtonInput)inputField).setChecked(checked.booleanValue());
77 }
78
79 protected String getInputType(){
80 return "radio";
81 }
82
83 }