Nice bug hunting there, thanks!
Will take a look, add some selenium tests for DFW
and then fix...
From Pablo Nussembaum <[EMAIL PROTECTED]>:
> We've recently started migrating one of our applications from Tapestry 3 to
> Tapestry 4. We make an extensive use of the component DirtyFormWarning(DFW)
> from the Tacos library, having, of course, installed their new version for
> Tapestry 4, and everything worked out fine until we came across a LinkSubmit
> in one of our Forms.
> When we use a LinkSubmit to submit a form, we get the warning from the DFW
> that obviously we shouldn't get. Now, DFW does the check every time the user
> leaves a page by any means, and in the case it's trough a submit it just
> doesn't show the warning. To accomplish this, it adds the following to the
> page source:
> var oldSubmit = form.onsubmit;form.onsubmit = function() {
> setDirtyFormWarning(false); return oldSubmit ? oldSubmit() : true; }
> So, if a user clicks a submit button (that is, a <input
> type=�submit��>), or by any means
> the form.submit() method is called,
> the warning would not be displayed.
> When we use a Submit component we are in that first case, so everything works
> fine, but where we have LinkSubmits instead,the warning is always shown and
> we suspect its cause is in the script Form.js that is included with every
> Form.We noticed that the HTML rendered by a LinkSubmit doesn't call directly
> the method form.submit(),but instead calls Tapestry.submit_form(�)
> defined
> in org/apache/tapestry/form/Form.js, which calls the submit method on
> FormEventManager, which code we paste here:
> FormEventManager.prototype.submit = function(name)
> {if (this.onsubmit_handler()){this.form.onsubmit =
> null;this.form.submitname.value = name;this.form.submit();}}
>
>
> In bold is the line where we think the problem is. The listener added by DFW
> is lost there.In that same script, Form.js, we found the method
> Tapestry.onsubmit(...) that adds a listener to an array. All the listeners
> there will be called in onsubmit_handler().We made a small change in the DFW
> components to get it work, this is the change code:
> in file: net.sf.tacos.form.DirtyFormWarning.scriptActual code:
> var oldSubmit = form.onsubmit;form.onsubmit = function() {
> setDirtyFormWarning(false); return oldSubmit ? oldSubmit() : true; }
> Modified code:
> Tapestry.onsubmit("${formName}", function() { setDirtyFormWarning(false);
> return true; });
>
> Thanks
> --Pablo Nussembaum
>
> Using Tomcat but need to do more? Need to support web services, security?Get
> stuff done quickly with pre-integrated technology to make your job
> easierDownload IBM WebSphere Application Server v.1.0.1 based on Apache
>
Geronimohttp://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642_______________________________________________Tacos-devel
> mailing
>
[EMAIL PROTECTED]://lists.sourceforge.net/lists/listinfo/tacos-devel
>
--
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Tacos-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tacos-devel