01: // Copyright © 2002-2005 Canoo Engineering AG, Switzerland.
02: package com.canoo.webtest.steps.form;
03:
04: /**
05: * Base class for steps which update a named field within a form.
06: *
07: * @author Marc Guillemot
08: * @author Paul King
09: */
10: public abstract class AbstractSetNamedFieldStep extends
11: AbstractSetFieldStep {
12: protected static final String DEFAULT_VALUE_NULL_MESSAGE = "Attribute \"value\" must be set or inner text must be supplied!";
13: private String fValue;
14:
15: /**
16: * Set the value
17: *
18: * @param value
19: * @webtest.parameter
20: * required="yes"
21: * description="The value to use when setting the field of interest."
22: */
23: public void setValue(final String value) {
24: fValue = value;
25: }
26:
27: public String getValue() {
28: return fValue;
29: }
30:
31: protected boolean isValueNull() {
32: return fValue == null;
33: }
34:
35: /**
36: * Called by ant to set the text contained in the tag.
37: * An alternative to value="blabla" for e.g. Large TextAreas. Usage:<br/>
38: * <setInputField>blabla<br/>
39: * blibli<br/>
40: * </setInputField>
41: *
42: * @param str the text value to add
43: * @webtest.nested.parameter
44: * required="no"
45: * description="An alternative to the attribute value for e.g. large TextAreas."
46: */
47: public void addText(final String str) {
48: final String strExpanded = getProject().replaceProperties(str);
49: if (fValue == null) {
50: setValue(strExpanded);
51: } else {
52: setValue(fValue + strExpanded);
53: }
54: }
55: }
|