hlship / tapx

Extensions to Tapestry 5
http://tapestry.formos.com/projects/tapx/
29 stars 7 forks source link

Using Confirm mixin on a Submit component can screw up the page activation context on submit #6

Closed hlship closed 14 years ago

hlship commented 14 years ago

My page has a numeric page activation context (a Hibernate entity id). This shows up in the form:

 <form onsubmit="javascript:return Tapestry.waitForPage(event);" action="/confirmbid.confirm" method="post" id="confirm"><div class="t-invisible"><input value="5003000" name="t:ac" type="hidden"></input><input value="H4sIAAAAAAAAAE2OvQ4BQRSFr02IRERQ6dWj0tCIrSQbkewTzM5ea+z8mRmWRuUlvIOSx9J4AmslojnnfMlXnNsT6kUH2qFWa27lnKcTnTsLM20zQg1lGySeGnTensaEaYuCJ2VLoxUq70i8TyT3w5XVDJ2ryDmu1TV+DR73SxhAEEGTCV7ai9RDL9rSAx0JqrJR7C1X2TSCFgqUpbCkEndwhtrReAh0XkXRh+7fPUYVQ+E+GnhofPE33iKZZBTQAAAA" name="t:formdata" type="hidden"></input></div> 

However, when the form is submitted, after the confirm dialog, the form submits, but the redirect URL after submission is /confirmbid/undefined

hlship commented 14 years ago

This appears to happen in Chrome and FF.

The request comes up very oddly:

GET /confirmpac/undefined HTTP/1.1
Host: localhost:8080
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4
Referer: http://localhost:8080/confirmpac/1
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: JSESSIONID=1s5f6uwg5ae18

The rendered HTML looks fine:

<form onsubmit="javascript:return Tapestry.waitForPage(event);" action="/confirmpac.form" method="post" id="form"><div class="t-invisible"><input value="1" name="t:ac" type="hidden"></input><input value="H4sIAAAAAAAAAFvzloG1XIxBxDk/Ly2zKDcgMdkqMy+5KDU3Na+kuIjBIb8oXS+xIDE5I1WvJLEgtbikqNJULzm/KDUnMwlI5xbk54FU6gWXJuVmlqgEFOUnpxYXg3nFxZn5eTODP0lu3dLizMTA5MPAkZyTCVTtmVLCIOSTlViWqJ+TmJeuH1xSlJmXbu3DwJ2aA7bYLzE3tZChjoGxoqCEgRPuHmQ2ALpXX4S4AAAA" name="t:formdata" type="hidden"></input></div><input value="Increment Value" id="increment" name="increment" type="submit"></input></form>
hlship commented 14 years ago

That's what's wierd: action="/confirmpac.form" and there's nothing special going on with the Form (no client-side validation, etc.) I just don't see where "/confirmpac/undefined" can be coming from!

hlship commented 14 years ago

Ah, I think I found it. The logic for handling an element with a click handler, but no Tapestry action, was missing a return, causing the window.location to be updated as well. Yowza!

hlship commented 14 years ago

Fix confirm.js to handle the case where a submit (with no Tapestry action) is triggered

Closed by 6947f4dff92c985e9d85df3f37acdf9c1ccdbe3f