power-media / prado3

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

Buttons stops working properly after response->writeFile #434

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Original discussion on the forum:
http://www.pradoframework.com/forum/index.php?topic=8721.0

What steps will reproduce the problem?
1. add a  TButton and another postback control (es TLinkButton) on a page
2. use the TLinkButton to download a file using es. 
$this->response->writeFile(); exit();
3. this generates an incomplete response from prado, and PRADO_POSTBACK_TARGET 
still points to the TlinkButton
4) From now on, every click to the TButton will act like if the TLinkButton had 
been clicked instead

This is caused by some optimization code present in 
TButton::needPostBackScript(). If the button has no special options set, this 
causes prado not to output the javascript code needed to create the javascript 
postback object but to create a simple <input type=submit > instead.
When the TLinkButton in the example makes its request, it sets 
PRADO_POSTBACK_TARGET; since the response is not actually the full page as 
rendere by prado, that field doesn't get reset to an empty string.
The following requests made with the TButton won't set correctly 
PRADO_POSTBACK_TARGET since the button is a "simple" one. Prado on the 
serverside will continue to see the old value of PRADO_POSTBACK_TARGET and 
think that the TLinkButton caused the postback.

Original issue reported on code.google.com by ctrlal...@gmail.com on 21 Jan 2013 at 4:23

GoogleCodeExporter commented 8 years ago
Quick workaround: set ButtonType="Button" on the TButton. This will cause prado 
to always emit the javascript for that button.

The correct patch is to make the javascript reset the value of 
PRADO_POSTBACK_TARGET just after the request. I have a working patch but i need 
to ensure that it doesn't break anything else before committing.

Original comment by ctrlal...@gmail.com on 21 Jan 2013 at 4:24

GoogleCodeExporter commented 8 years ago
fixed in r3259

Original comment by ctrlal...@gmail.com on 21 Jan 2013 at 6:36