Quantcast

[ htmlunit-Bugs-1306033 ] image button with onclick isn't included in form parameters

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[ htmlunit-Bugs-1306033 ] image button with onclick isn't included in form parameters

SourceForge.net
Bugs item #1306033, was opened at 2005-09-27 18:47
Message generated for change (Comment added) made by mguillem
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1306033&group_id=47038

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: 1.7
Status: Open
Resolution: None
Priority: 5
Submitted By: Rodney Gitzel (rgitzel)
Assigned to: Nobody/Anonymous (nobody)
Summary: image button with onclick isn't included in form parameters

Initial Comment:
(This is using 1.7... the "Group" dropdown only goes to
1.6?)

Currently our app uses multiple image buttons to submit
a given form, and we determine which button was pressed
by looking for "name.x" and "name.y" in the parameters.
 Works fine, and HtmlUnit handles it fine.

Now we are changing the app to display the results of
the same form in a popup when one specific button is
pressed, and in the same window for the rest.   No
problem:  use onclick for that one button to open the
new window and change the target of the form.  Works
fine -- but HtmlUnit does NOT handle it.

I found that HtmlUnit would correctly create the new
HtmlPage, correctly redirect the output to that new
page... but was not putting the ".x" and ".y" values
into the parameter list, so our code doesn't know what
button was pressed.

I traced the code and found that once the Javascript
was invoked, the fact that the button had been pressed
seemed to get lost. The form would be properly
submitted, but for some reason the buttons were not
included in the parameter list.

Eventually I made two minor changes in HtmlForm that
seem to fix the problem by making the buttons
'submittable'  (diff attached).

(A side effect is that all image button names now
appear as parameters, but with value "".  I think
HtmlImageInput.getSubmitKeyValuePairs() could be
modified to not output ANYthing if
wasPositionSpecified_ is false to deal with this.)

This seems to fix our problem, and seems to cause no
regression issues on our tests, but I haven't run your
test suite on it.

Cheers!  :-)



----------------------------------------------------------------------

>Comment By: Marc Guillemot (mguillem)
Date: 2005-10-12 18:17

Message:
Logged In: YES
user_id=402164

I don't understand your unit test: you open a window with
the string conversion of the form as url. For Firefox this
gives "[object HtmlFormElement]" and for IE: "[object]". I
doubt that this is the url you want to open.

----------------------------------------------------------------------

Comment By: Rodney Gitzel (rgitzel)
Date: 2005-09-30 22:33

Message:
Logged In: YES
user_id=148993

Interesting.  It works with the fixes I described, though
the test I provided fails due to too many extraneous paramters.

However, making the change suggested in 1285430 instead
fixes it perfectly, it seems.



----------------------------------------------------------------------

Comment By: Rodney Gitzel (rgitzel)
Date: 2005-09-30 22:16

Message:
Logged In: YES
user_id=148993

Okay, attached is a new test method.  

In the onclick Javascript (which attempts to open a new
window for the form output), if you change the return value
at the end to 'true' then the test succeeds.  But that
doesn't work in a browser of course, since the browser then
tries to update the main window.



----------------------------------------------------------------------

Comment By: Rodney Gitzel (rgitzel)
Date: 2005-09-29 01:40

Message:
Logged In: YES
user_id=148993

I'll give a go once I've your tests running in my
environment.  Thanks.

----------------------------------------------------------------------

Comment By: Marc Guillemot (mguillem)
Date: 2005-09-28 08:59

Message:
Logged In: YES
user_id=402164

Can you provide a unit test?

----------------------------------------------------------------------

Comment By: Rodney Gitzel (rgitzel)
Date: 2005-09-28 02:57

Message:
Logged In: YES
user_id=148993

I had to make an additional change, this time to
HtmlImageInput, to clear the fact that the image had been
clicked, in situations where I re-submit the form.  (Sorry,
couldn't get a diff, here's the method.)

    public Page click( final int x, final int y )
        throws
            IOException,
            ElementNotFoundException {

        Page p ;
       
        wasPositionSpecified_ = true;
        xPosition_ = x;
        yPosition_ = y;
       
        p = super.click() ;
       
        // reset this or the form will carry it over to next
submit
        wasPositionSpecified_ = false;
       
        return( p ) ;
    }


----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1306033&group_id=47038


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
Loading...