[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit FormControl.java,1.36,1.37
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2003-03-13 18:21:30
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv16661/src/com/meterware/httpunit
Modified Files:
FormControl.java
Log Message:
Added support for select.value
Index: FormControl.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- FormControl.java 17 Feb 2003 23:54:40 -0000 1.36
+++ FormControl.java 13 Mar 2003 18:20:49 -0000 1.37
@@ -855,6 +855,8 @@
return _selectionOptions;
} else if (propertyName.equalsIgnoreCase( "length" )) {
return new Integer( getOptionValues().length );
+ } else if (propertyName.equalsIgnoreCase( "value" )) {
+ return getSelectedValue();
} else if (propertyName.equalsIgnoreCase( "selectedIndex" )) {
return new Integer( _selectionOptions.getFirstSelectedIndex() );
} else {
@@ -863,8 +865,17 @@
}
+ private String getSelectedValue() {
+ String[] values = getValues();
+ return (values.length == 0 ? "" : values[0] );
+ }
+
+
public void set( String propertyName, Object value ) {
if (propertyName.equalsIgnoreCase( "value" )) {
+ ArrayList values = new ArrayList();
+ values.add( value );
+ _selectionOptions.claimUniqueValues( values );
} else if (propertyName.equalsIgnoreCase( "selectedIndex" )) {
if (!(value instanceof Number)) throw new RuntimeException( "selectedIndex must be set to an integer" );
_selectionOptions.setSelectedIndex( ((Number) value).intValue() );
|