Nice analysis!

On Mon, Jan 17, 2011 at 4:21 PM, Josh Canfield <joshcanfi...@gmail.com> wrote:
> Hey, thanks for the concise example to reproduce the problem!
>
> Yes, it's a bug. Tapestry tracks clicks to submit buttons:
> $$("INPUT[type=submit]").each(function(element) {
>
> Image submit inputs have a type of "image", not "submit" so they are
> ignored and don't set the tracking info. Tapestry still remembers that
> you clicked the "select all" button so when you submit via the image
> you get two hits, once for the actual button that was clicked and once
> for the submit you hit before clicking the image.
>
> The brute force workaround is copy the code from tapestry.js and apply
> it to your affected page (after your form so that everything is in the
> DOM)
>
> <script  type="text/javascript">
>        $$("INPUT[type=image]").each(function(element) {
>                        var t = $T(element);
>
>                        if (!t.trackingClicks) {
>                                element.observe("click", function() {
>                                        
> $(element.form).setSubmittingElement(element);
>                                });
>
>                                t.trackingClicks = true;
>                        }
>                });
>    </script>
>
> I'll file a defect now and submit the fix to the 5.3 branch. I'm not
> setup to do fixes to older versions right now, but I'll try to get to
> it before the next patch release.
>
> Josh
>
> On Mon, Jan 17, 2011 at 2:21 PM, Stephan Windmüller
> <stephan.windmuel...@tu-dortmund.de> wrote:
>> On 17.01.2011 17:15, Taha Hafeez wrote:
>>
>>>> The "select all" button works with or without JavaScript. This is
>>>> achieved by this code:
>>> It works without javascript because the select-all button is used as a
>>> simple submit button when javascript is disabled
>>> and so when it is clicked it submits the form and at the server side,
>>> Tapestry executes onSelectFromSelectAll()
>>
>> That's correct and is exactly the way I wanted it to be.
>>
>>>> My problem is: This page does not work when I click the "select all"
>>>> button with activated JavaScript and then "submit". It does work, when I
>>>> select all fields manually and submitting after that or when JavaScript
>>>> is disabled.
>>> When you click "select-all" with javascript enabled the form is not
>>> submitted and all it does is enable the checkboxes
>>> at the client end. Nothing happens at the server end.
>>
>> That's also correct.
>>
>>> When you click "submit" only then the form is submitted and as the submit
>>> button value is 'submit', only
>>> onSelectedFromSubmit() is called and onSelectedFromSelectAll() is not
>>> called...
>>
>> And this is not what I got here. Did you try the code I sent? You have
>> to do both:
>>
>> 1. Click on "select all" with JavaScript enabled
>> 2. Submit the form
>>
>> The first step will not produce any output because the server is not
>> called. But during step two, onSelectedFromSelectAll() is called and
>> that is what should not happen.
>>
>> Again, this only happens with submit buttons having an image tag. If I
>> remove it, all works fine.
>>
>> So for me it looks like a bug in the component. It should not behave
>> differently during the submit when an image is specified.
>>
>> - Stephan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to