[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit FormControl.java,1.25,1.26
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2002-10-01 18:05:13
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv28436/src/com/meterware/httpunit
Modified Files:
FormControl.java
Log Message:
bug #617065: corrected handling of Javascript for drop-down boxes
Index: FormControl.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- FormControl.java 27 Sep 2002 16:30:13 -0000 1.25
+++ FormControl.java 1 Oct 2002 18:05:10 -0000 1.26
@@ -887,6 +887,7 @@
private boolean _defaultSelected;
private boolean _selected;
private int _index;
+ private Options _container;
Option() {
@@ -910,7 +911,8 @@
}
- void setIndex( int index ) {
+ void setIndex( Options container, int index ) {
+ _container = container;
_index = index;
}
@@ -958,6 +960,7 @@
public void setSelected( boolean selected ) {
_selected = selected;
+ if (selected) _container.optionSet( _index );
}
@@ -980,7 +983,7 @@
_options[i] = new Option( getValue( nl.item(i).getFirstChild() ),
getOptionValue( nl.item(i) ),
nl.item(i).getAttributes().getNamedItem( "selected" ) != null );
- _options[i].setIndex(i);
+ _options[i].setIndex( this, i );
}
}
@@ -1082,7 +1085,16 @@
expandOptionsArray();
}
_options[i] = (Option) option;
- _options[i].setIndex(i);
+ _options[i].setIndex( this, i );
+ if (option.isSelected()) ensureUniqueOption(i);
+ }
+ }
+
+
+ private void ensureUniqueOption( int i ) {
+ if (_multiSelect) return;
+ for (int j = 0; j < _options.length; j++) {
+ _options[j]._selected = (i == j);
}
}
@@ -1104,6 +1116,12 @@
public Object get( int index ) {
return _options[ index ];
+ }
+
+
+ /** Invoked when an option is set true. **/
+ void optionSet( int i ) {
+ ensureUniqueOption(i);
}
|