tel8618217223380 / prado3

Automatically exported from code.google.com/p/prado3
Other
0 stars 0 forks source link

When TPanel's DefaultButton property is set to a TActiveButton it inhibits TButton's postback #319

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Open the attached testcase
2.  Trigger the callback pressing the TActiveButton and then trigger the 
postback using the TButton, everything works.
3. Focus the TTextBox and trigger the callback pressing "Enter/Return" on the 
keyboard (the TPanel's DefaultButton is the TActiveButton): the callback will 
be executed.
4. Now press the TButton to trigger a postback.

What is the expected output? What do you see instead?

The first postback will be made but the TButton's OnCommand functions won't be 
executed. If you try to postback one more time, it will work.
Trying to postback from the TButton ouside the TPanel won't work either.

What version of the product are you using? On what operating system?
Tested on both prado 3.1.7 and trunk/ under Slackware64 Linux 13.37/php 5.3.6

Please provide any additional information below.

Original issue reported on code.google.com by ctrlal...@gmail.com on 3 May 2011 at 2:49

Attachments:

GoogleCodeExporter commented 9 years ago
After some debugging, the bug is caused by line
http://code.google.com/p/prado3/source/browse/branches/3.1/framework/Web/Javascr
ipts/source/prado/controls/controls.js#214 :
 $('PRADO_POSTBACK_TARGET').value = this.options.EventTarget;
While this is harmless the the DefaultButton is a TButton, it causes a problem 
when the DefaultButton is a TActiveButton.

Simple postback parameters you expect on a normal page:
PRADO_POSTBACK_TARGET=testButtonPost&PRADO_POSTBACK_PARAMETER=undefined&txtDummy
=

Simple callback parameters you expect on a normal page:
PRADO_CALLBACK_TARGET=testButtonCall&PRADO_POSTBACK_TARGET=testButtonCall

Postback parameters from the testcase page:
PRADO_POSTBACK_TARGET=&PRADO_POSTBACK_PARAMETER=&txtDummy=&testButtonPost=Postba
ck
This works anyway, since the last parameter is intercepted in 
TPage::processPostData() and set as FIELD_POSTBACK_TARGET

Callback parameters from the testcase page when hitting enter on the TTextBox:
PRADO_CALLBACK_TARGET=testButtonCall&PRADO_POSTBACK_TARGET=testButtonCall
Both targets are set

Postback parameters after the callback caused by DefaultButton handling (the 
broken one):
PRADO_POSTBACK_TARGET=testButtonCall&PRADO_POSTBACK_PARAMETER=&txtDummy=&testBut
tonPost=Postback
As you can see, PRADO_POSTBACK_TARGET has not been reset, so 
TPage::processPostData() won't pick up testButtonPost as the 
FIELD_POSTBACK_TARGET; it will re-execute the previous callback instead.

The easier fix is just to comment out the offending line in controls.js.
I've tested a lot of testcase combinations, all of them works with this change; 
i also tried adding a TRequiredFieldValidator and a TActiveCustomValidator to 
ensure removing that line won't affect proper validation.

Another fix could be forcing PRADO_POSTBACK_TARGET for each postback, but 
looking at the way Prado.Postback works it seems that it's not possible.

Original comment by ctrlal...@gmail.com on 3 May 2011 at 8:39

GoogleCodeExporter commented 9 years ago
Fixe in r2906

Original comment by ctrlal...@gmail.com on 10 May 2011 at 8:23