[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit ResetButton.java,NONE,1.1 Button.java,1.1
Brought to you by:
russgold
From: Russell G. <rus...@us...> - 2002-08-27 16:26:07
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv9481/src/com/meterware/httpunit Modified Files: Button.java FormControl.java WebForm.java Added Files: ResetButton.java Log Message: Added support for reset button and associated JavaScript ***** Error reading new file[Errno 2] No such file or directory: 'ResetButton.java' Index: Button.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/Button.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Button.java 19 Aug 2002 18:52:25 -0000 1.1 +++ Button.java 27 Aug 2002 16:26:03 -0000 1.2 @@ -64,8 +64,15 @@ } + final protected boolean doOnClickEvent() { return _onClickEvent.length() == 0 || getScriptableObject().doEvent( _onClickEvent ); + } + + + final + protected WebForm getForm() { + return _form; } Index: FormControl.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/FormControl.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- FormControl.java 21 Aug 2002 03:45:01 -0000 1.20 +++ FormControl.java 27 Aug 2002 16:26:03 -0000 1.21 @@ -269,6 +269,8 @@ final String type = NodeUtils.getNodeAttribute( node, "type", "submit" ); if (type.equalsIgnoreCase( "submit" )) { return new SubmitButton( form, node ); + } else if (type.equalsIgnoreCase( "reset" )) { + return new ResetButton( form, node ); } else { return new Button( form, node ); } @@ -289,7 +291,7 @@ } else if (type.equalsIgnoreCase( "button" )) { return new Button( form, node ); } else if (type.equalsIgnoreCase( "reset" )) { - return new Button( form, node ); + return new ResetButton( form, node ); } else if (type.equalsIgnoreCase( "file" )) { return new FileSubmitFormControl( node ); } else { Index: WebForm.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- WebForm.java 23 Aug 2002 19:33:12 -0000 1.60 +++ WebForm.java 27 Aug 2002 16:26:04 -0000 1.61 @@ -118,6 +118,18 @@ /** + * Returns the button with the specified ID + */ + public Button getButtonWithID( String buttonID ) { + Button[] buttons = getButtons(); + for (int i = 0; i < buttons.length; i++) { + if (buttons[i].getID().equalsIgnoreCase( buttonID )) return buttons[i]; + } + return null; + } + + + /** * Returns an array containing the submit buttons defined for this form. **/ public SubmitButton[] getSubmitButtons() { @@ -319,6 +331,12 @@ * Resets all parameters to their initial values. */ public void reset() { + String event = NodeUtils.getNodeAttribute( getNode(), "onreset" ); + if (event.length() == 0 || getScriptableObject().doEvent( event )) resetControls(); + } + + + private void resetControls() { FormControl[] controls = getFormControls(); for (int i = 0; i < controls.length; i++) { controls[i].reset(); @@ -471,6 +489,11 @@ public void submit() throws IOException, SAXException { submitRequest( getScriptedSubmitRequest() ); + } + + + public void reset() throws IOException, SAXException { + resetControls(); } |