[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit Button.java,1.8,1.9 SubmitButton.java,1.1
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2003-05-23 03:09:30
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory sc8-pr-cvs1:/tmp/cvs-serv24044/src/com/meterware/httpunit
Modified Files:
Button.java SubmitButton.java WebForm.java
WebRequestSource.java
Log Message:
bug #722788: form submit now invokes button's onclick event
Index: Button.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/Button.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Button.java 4 Apr 2003 14:20:11 -0000 1.8
+++ Button.java 23 May 2003 03:09:27 -0000 1.9
@@ -68,8 +68,11 @@
}
- final
- protected boolean doOnClickEvent() {
+ /**
+ * Does the 'onClick' event defined for this button.
+ * @return true if subsequent actions should be performed.
+ */
+ final protected boolean doOnClickEvent() {
return _onClickEvent.length() == 0 || getScriptableDelegate().doEvent( _onClickEvent );
}
Index: SubmitButton.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/SubmitButton.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- SubmitButton.java 17 Feb 2003 23:54:41 -0000 1.15
+++ SubmitButton.java 23 May 2003 03:09:27 -0000 1.16
@@ -44,7 +44,7 @@
* Perform the normal action of this button.
*/
protected void doButtonAction() throws IOException, SAXException {
- getForm().submit( this );
+ getForm().doFormSubmit( this );
}
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- WebForm.java 2 Apr 2003 15:31:05 -0000 1.83
+++ WebForm.java 23 May 2003 03:09:27 -0000 1.84
@@ -56,11 +56,19 @@
/**
* Submits this form using the web client from which it was originally obtained.
- * Will usually return the result of that submission; however, if the 'onsubmit' event is triggered and
- * inhibits the submission, will return the updated contents of the frame containing this form. Note that
- * this will not run any event associated with the specified submit button. Use SubmitButton#click for that.
+ * Will usually return the result of that submission; however, if the submit button's 'onclick'
+ * or the form's 'onsubmit' event is triggered and
+ * inhibits the submission, will return the updated contents of the frame containing this form.
**/
public WebResponse submit( SubmitButton button ) throws IOException, SAXException {
+ return button.doOnClickEvent() ? doFormSubmit( button ) : getCurrentFrameContents();
+ }
+
+
+ /**
+ * Submits the form without also invoking the button's "onclick" event.
+ */
+ WebResponse doFormSubmit( SubmitButton button ) throws IOException, SAXException {
return submitRequest( getAttribute( "onsubmit" ), getRequest( button ) );
}
Index: WebRequestSource.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebRequestSource.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- WebRequestSource.java 2 Apr 2003 15:31:05 -0000 1.28
+++ WebRequestSource.java 23 May 2003 03:09:27 -0000 1.29
@@ -214,8 +214,13 @@
protected WebResponse submitRequest( String event, final WebRequest request ) throws IOException, SAXException {
WebResponse response = null;
if (event.length() == 0 || getScriptableDelegate().doEvent( event )) response = submitRequest( request );
- if (response == null) response = getCurrentFrame( getBaseResponse().getWindow(), getPageFrame() );
+ if (response == null) response = getCurrentFrameContents();
return response;
+ }
+
+
+ protected WebResponse getCurrentFrameContents() {
+ return getCurrentFrame( getBaseResponse().getWindow(), getPageFrame() );
}
|