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 /***
22 * A tag which sets a file field to the provided value.
23 * <br/>
24 * To use XPath to set a file field named <b>testFileField</b> that exists in a form with the id <b>testform</b>:
25 * <pre><source>
26 * <htmlunit-set-file-field
27 * functionId="Set the testFileField field to '/tmp/files/my_file.tar.gz'"
28 * xpath="//form[@id='testform']/input[@name='testFileField']"
29 * value="/tmp/files/my_file.tar.gz"/>
30 * </source></pre>
31 * To use XPath to set a file field named <b>testFileField</b> that doesn't exist in a form:
32 * <pre><source>
33 * <htmlunit-set-text-field
34 * functionId="Set the testFileField field to 'some value' and set it against type just for grins."
35 * xpath="//input[@name='testFileField' and @type='file']"
36 * value="some value"/>
37 * </source></pre>
38 * @jameleon.function name="htmlunit-set-file-field" type="action"
39 */
40 public class HtmlUnitSetFileFieldTag extends AbstractHtmlUnitSetInputFieldTag{
41
42 protected String getInputType(){
43 return "file";
44 }
45
46 protected void setFieldValueInForm(){
47 if (value != null) {
48 setFileField(fieldName, value);
49 }
50 }
51
52 }