diff options
15 files changed, 224 insertions, 61 deletions
diff --git a/.gitattributes b/.gitattributes index 2a91e060..102eddc9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2039,6 +2039,8 @@ tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest. tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonListTest.php -text tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.page -text tests/FunctionalTests/active-controls/protected/pages/ActiveRadioButtonTest.php -text +tests/FunctionalTests/active-controls/protected/pages/ActiveRedirectionTest.page -text +tests/FunctionalTests/active-controls/protected/pages/ActiveRedirectionTest.php -text tests/FunctionalTests/active-controls/protected/pages/CallbackCustomValidatorTest.page -text tests/FunctionalTests/active-controls/protected/pages/CallbackCustomValidatorTest.php -text tests/FunctionalTests/active-controls/protected/pages/CustomTemplateComponent.php -text @@ -2058,6 +2060,10 @@ tests/FunctionalTests/active-controls/protected/pages/InPlaceWithValidator.page tests/FunctionalTests/active-controls/protected/pages/InPlaceWithValidator.php -text tests/FunctionalTests/active-controls/protected/pages/LTemplate.php -text tests/FunctionalTests/active-controls/protected/pages/LTemplate.tpl -text +tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest.page -text +tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest.php -text +tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest2.page -text +tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest2.php -text tests/FunctionalTests/active-controls/protected/pages/Master1.php -text tests/FunctionalTests/active-controls/protected/pages/Master1.tpl -text tests/FunctionalTests/active-controls/protected/pages/MasterTest1.page -text diff --git a/demos/quickstart/protected/pages/ActiveControls/Home.page b/demos/quickstart/protected/pages/ActiveControls/Home.page index bef855c9..5b8c40a2 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Home.page @@ -14,7 +14,8 @@ of <a href="?page=ActiveControl.ClientSideJavascript">javascript classes</a>. </p>
<p>For a quick demo of active controls, try the <a href="?page=ActiveControls.ActiveButton">
-TActiveButton</a> control.</p>
+TActiveButton</a> control. See also the later part of the <a href="?page=Tutorial.CurrencyConverter">Current Converter</a> tutorial for a more indepth example.
+</p>
<p>* the tutorial for this control is not completed yet.</p>
@@ -158,146 +159,151 @@ TActiveButton</a> control.</p> </ul>
<h2>Active Control Abilities</h2>
-
-<!-- tabular: align=|l|l|l|l|, width=(0.35 0.15 0.15 0.15) -->
+<p>The following table shows the Active Controls that can trigger a
+callback event and whether the control will raise a PostBack event
+if Javascript was disabled on the client's browser.</p>
+<!-- tabular: align=|l|l|l|, width=(0.35 0.25 0.25) -->
<table class="tabular">
<tr>
<th>Control Name</th>
- <th>Can Update</th>
<th>Triggers Callback</th>
- <th>Can Degrade</th>
+ <th>Falls back to PostBack</th>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveButton">TActiveButton</a>
</td>
- <td>Yes</td><td>Yes</td><td>Yes</td>
+ <td>Yes</td>
+ <td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveCheckBox">TActiveCheckBox</a>
</td>
- <td>Yes</td><td>Yes</td><td>Yes</td>
+ <td>Yes</td>
+ <td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveCustomValidator">TActiveCustomValidator</a>
</td>
- <td>No</td><td>Yes</td><td>No</td>
+ <td>Yes</td>
+ <td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveHyperLink">TActiveHyperLink</a>
</td>
- <td>Yes</td><td>No</td><td>Yes</td>
+ <td>No</td><td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveImage">TActiveImage</a>
</td>
- <td>Yes</td><td>No</td><td>Yes</td>
+ <td>No</td><td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveImageButton">TActiveImageButton</a>
</td>
- <td>Yes</td><td>Yes</td><td>Yes</td>
+ <td>Yes</td><td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveLabel">TActiveLabel</a>
</td>
- <td>Yes</td><td>No</td><td>Yes</td>
+ <td>No</td><td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveLinkButton">TActiveLinkButton</a>
</td>
- <td>Yes</td><td>Yes</td><td>No</td>
+ <td>Yes</td><td>No</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActivePanel">TActivePanel</a>
</td>
- <td>Yes</td><td>No</td><td>Yes</td>
+ <td>No</td><td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveRadioButton">TActiveRadioButton</a>
</td>
- <td>Yes</td><td>Yes</td><td>Yes</td>
+ <td>Yes</td><td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveTextBox">TActiveTextBox</a>
</td>
- <td>Yes</td><td>Yes</td><td>Yes</td>
+ <td>Yes</td><td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.CallbackOptions">TCallbackOptions</a>
</td>
- <td>No</td><td>No</td><td>N/A</td>
+ <td>No</td><td>N/A</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveCheckBoxList">TActiveCheckBoxList</a>
</td>
- <td>Yes</td><td>Yes</td><td>Yes</td>
+ <td>Yes</td><td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveDropDownList">TActiveDropDownList</a>
</td>
- <td>Yes</td><td>Yes</td><td>Yes</td>
+ <td>Yes</td><td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveListBox">TActiveListBox</a>
</td>
- <td>Yes</td><td>Yes</td><td>Yes</td>
+ <td>Yes</td><td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ActiveRadioButtonList">TActiveRadioButtonList</a>
</td>
- <td>Yes</td><td>Yes</td><td>Yes</td>
+ <td>Yes</td><td>Yes</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.AutoComplete">TAutoComplete</a>
</td>
- <td>Yes</td><td>Yes</td><td>Yes</td>
+ <td>Yes</td>
+ <td>No</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.Callback">TCallback</a>
</td>
- <td>No</td><td>Yes</td><td>No</td>
+ <td>Yes</td><td>No</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.EventTriggeredCallback">TEventTriggeredCallback</a>
</td>
- <td>No</td><td>Yes</td><td>No</td>
+ <td>Yes</td><td>No</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.InPlaceTextBox">TInPlaceTextBox</a>
</td>
- <td>Yes</td><td>Yes</td><td>No</td>
+ <td>Yes</td><td>No</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.TimeTriggeredCallback">TTimeTriggeredCallback</a>
</td>
- <td>No</td><td>Yes</td><td>No</td>
+ <td>Yes</td><td>No</td>
</tr>
<tr><td>
<a href="?page=ActiveControls.ValueTriggeredCallback">TValueTriggeredCallback</a>
</td>
- <td>No</td><td>Yes</td><td>No</td>
+ <td>Yes</td><td>No</td>
</tr>
</table>
diff --git a/framework/Web/Javascripts/js/compressed/ajax.js b/framework/Web/Javascripts/js/compressed/ajax.js index e4756b94..1040070d 100644 --- a/framework/Web/Javascripts/js/compressed/ajax.js +++ b/framework/Web/Javascripts/js/compressed/ajax.js @@ -21,23 +21,27 @@ response=response.stripScripts();if(receiver){if(this.options.insertion){new thi if(this.responseIsSuccess()){if(this.onComplete) setTimeout(this.onComplete.bind(this),10);}}});Ajax.PeriodicalUpdater=Class.create();Ajax.PeriodicalUpdater.prototype=Object.extend(new Ajax.Base(),{initialize:function(container,url,options){this.setOptions(options);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=container;this.url=url;this.start();},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent();},stop:function(){this.updater.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments);},updateComplete:function(request){if(this.options.decay){this.decay=(request.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=request.responseText;} this.timer=setTimeout(this.onTimerEvent.bind(this),this.decay*this.frequency*1000);},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options);}});Object.extend(Ajax.Request.prototype,{respondToReadyState:function(readyState) -{var event=Ajax.Request.Events[readyState];var transport=this.transport,json=this.getHeaderData(Prado.CallbackRequest.DATA_HEADER);if(event=='Complete') -{if(this.header('X-PRADO-REDIRECT')) -document.location.href=this.header('X-PRADO-REDIRECT');if((this.header('Content-type')||'').match(/^text\/javascript/i)) +{var event=Ajax.Request.Events[readyState];var transport=this.transport,json=this.getBodyDataPart(Prado.CallbackRequest.DATA_HEADER);if(event=='Complete') +{var redirectUrl=this.getBodyContentPart(Prado.CallbackRequest.REDIRECT_HEADER);if(redirectUrl) +document.location.href=redirectUrl;if((this.header('Content-type')||'').match(/^text\/javascript/i)) {try {json=eval('('+transport.responseText+')');}catch(e) {if(typeof(json)=="string") json=Prado.CallbackRequest.decode(result);}} try -{Prado.CallbackRequest.updatePageState(this,transport);Ajax.Responders.dispatch('on'+transport.status,this,transport,json);Prado.CallbackRequest.dispatchActions(transport,this.getHeaderData(Prado.CallbackRequest.ACTION_HEADER));(this.options['on'+this.transport.status]||this.options['on'+(this.responseIsSuccess()?'Success':'Failure')]||Prototype.emptyFunction)(this,json);}catch(e){this.dispatchException(e);}} +{Prado.CallbackRequest.updatePageState(this,transport);Ajax.Responders.dispatch('on'+transport.status,this,transport,json);Prado.CallbackRequest.dispatchActions(transport,this.getBodyDataPart(Prado.CallbackRequest.ACTION_HEADER));(this.options['on'+this.transport.status]||this.options['on'+(this.responseIsSuccess()?'Success':'Failure')]||Prototype.emptyFunction)(this,json);}catch(e){this.dispatchException(e);}} try{(this.options['on'+event]||Prototype.emptyFunction)(this,json);Ajax.Responders.dispatch('on'+event,this,transport,json);}catch(e){this.dispatchException(e);} if(event=='Complete') this.transport.onreadystatechange=Prototype.emptyFunction;},getHeaderData:function(name) +{return this.getJsonData(this.header(name));},getBodyContentPart:function(name) +{if(typeof(this.transport.responseText)=="string") +return Prado.Element.extractContent(this.transport.responseText,name);},getJsonData:function(json) {try -{var json=this.header(name);return eval('('+json+')');} +{return eval('('+json+')');} catch(e) {if(typeof(json)=="string") -return Prado.CallbackRequest.decode(json);}}});Prado.CallbackRequest=Class.create();Object.extend(Prado.CallbackRequest,{FIELD_CALLBACK_TARGET:'PRADO_CALLBACK_TARGET',FIELD_CALLBACK_PARAMETER:'PRADO_CALLBACK_PARAMETER',FIELD_CALLBACK_PAGESTATE:'PRADO_PAGESTATE',FIELD_POSTBACK_TARGET:'PRADO_POSTBACK_TARGET',FIELD_POSTBACK_PARAMETER:'PRADO_POSTBACK_PARAMETER',PostDataLoaders:[],DATA_HEADER:'X-PRADO-DATA',ACTION_HEADER:'X-PRADO-ACTIONS',ERROR_HEADER:'X-PRADO-ERROR',PAGESTATE_HEADER:'X-PRADO-PAGESTATE',requestQueue:[],addPostLoaders:function(ids) +return Prado.CallbackRequest.decode(json);}},getBodyDataPart:function(name) +{return this.getJsonData(this.getBodyContentPart(name));}});Prado.CallbackRequest=Class.create();Object.extend(Prado.CallbackRequest,{FIELD_CALLBACK_TARGET:'PRADO_CALLBACK_TARGET',FIELD_CALLBACK_PARAMETER:'PRADO_CALLBACK_PARAMETER',FIELD_CALLBACK_PAGESTATE:'PRADO_PAGESTATE',FIELD_POSTBACK_TARGET:'PRADO_POSTBACK_TARGET',FIELD_POSTBACK_PARAMETER:'PRADO_POSTBACK_PARAMETER',PostDataLoaders:[],DATA_HEADER:'X-PRADO-DATA',ACTION_HEADER:'X-PRADO-ACTIONS',ERROR_HEADER:'X-PRADO-ERROR',PAGESTATE_HEADER:'X-PRADO-PAGESTATE',REDIRECT_HEADER:'X-PRADO-REDIRECT',requestQueue:[],addPostLoaders:function(ids) {var self=Prado.CallbackRequest;self.PostDataLoaders=self.PostDataLoaders.concat(ids);var list=[];self.PostDataLoaders.each(function(id) {if(list.indexOf(id)<0) list.push(id);});self.PostDataLoaders=list;},dispatchActions:function(transport,actions) @@ -52,8 +56,9 @@ self.Exception.onException(null,e);}}},Exception:{"on500":function(request,trans {var e=request.getHeaderData(Prado.CallbackRequest.ERROR_HEADER);Logger.error("Callback Server Error "+e.code,this.formatException(e));},'on200':function(request,transport,data) {if(transport.status<500) {var msg='HTTP '+transport.status+" with response : \n";if(transport.responseText.trim().length>0) -msg+=transport.responseText+"\n";if(typeof(data)!="undefined"&&data!=null) -msg+="Data : \n"+inspect(data)+"\n";data=request.getHeaderData(Prado.CallbackRequest.ACTION_HEADER);if(data&&data.length>0) +{var f=RegExp('(<!--X-PRADO[^>]+-->)([\\s\\S\\w\\W]*)(<!--//X-PRADO[^>]+-->)',"m");msg+=transport.responseText.replace(f,'')+"\n";} +if(typeof(data)!="undefined"&&data!=null) +msg+="Data : \n"+inspect(data)+"\n";data=request.getBodyDataPart(Prado.CallbackRequest.ACTION_HEADER);if(data&&data.length>0) {msg+="Actions : \n";data.each(function(action) {msg+=inspect(action)+"\n";});} Logger.info(msg);}},onException:function(request,e) @@ -72,7 +77,7 @@ return null;},dispatchNormalRequest:function(callback) {if(self.requestQueue.length>0) return self.dispatchQueue();}},updatePageState:function(request,transport) {var self=Prado.CallbackRequest;var pagestate=$(self.FIELD_CALLBACK_PAGESTATE);var enabled=request.options.EnablePageStateUpdate&&request.options.HasPriority;var aborted=self.currentRequest==null;if(enabled&&!aborted&&pagestate) -{var data=request.header(self.PAGESTATE_HEADER);if(typeof(data)=="string"&&data.length>0) +{var data=request.getBodyContentPart(self.PAGESTATE_HEADER);if(typeof(data)=="string"&&data.length>0) pagestate.value=data;else {if(typeof(Logger)!="undefined") Logger.warn("Missing page state:"+data);self.endCurrentRequest();return false;}} diff --git a/framework/Web/Javascripts/js/debug/ajax.js b/framework/Web/Javascripts/js/debug/ajax.js index ed5694cf..452a9ef8 100644 --- a/framework/Web/Javascripts/js/debug/ajax.js +++ b/framework/Web/Javascripts/js/debug/ajax.js @@ -298,12 +298,13 @@ Object.extend(Ajax.Request.prototype, respondToReadyState : function(readyState)
{
var event = Ajax.Request.Events[readyState];
- var transport = this.transport, json = this.getHeaderData(Prado.CallbackRequest.DATA_HEADER);
+ var transport = this.transport, json = this.getBodyDataPart(Prado.CallbackRequest.DATA_HEADER);
if (event == 'Complete')
{
- if(this.header('X-PRADO-REDIRECT'))
- document.location.href = this.header('X-PRADO-REDIRECT');
+ var redirectUrl = this.getBodyContentPart(Prado.CallbackRequest.REDIRECT_HEADER);
+ if(redirectUrl)
+ document.location.href = redirectUrl;
if ((this.header('Content-type') || '').match(/^text\/javascript/i))
{
@@ -321,7 +322,7 @@ Object.extend(Ajax.Request.prototype, {
Prado.CallbackRequest.updatePageState(this,transport);
Ajax.Responders.dispatch('on' + transport.status, this, transport, json);
- Prado.CallbackRequest.dispatchActions(transport,this.getHeaderData(Prado.CallbackRequest.ACTION_HEADER));
+ Prado.CallbackRequest.dispatchActions(transport,this.getBodyDataPart(Prado.CallbackRequest.ACTION_HEADER));
(this.options['on' + this.transport.status]
|| this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
@@ -350,9 +351,19 @@ Object.extend(Ajax.Request.prototype, */
getHeaderData : function(name)
{
+ return this.getJsonData(this.header(name));
+ },
+
+ getBodyContentPart : function(name)
+ {
+ if(typeof(this.transport.responseText)=="string")
+ return Prado.Element.extractContent(this.transport.responseText, name);
+ },
+
+ getJsonData : function(json)
+ {
try
{
- var json = this.header(name);
return eval('(' + json + ')');
}
catch (e)
@@ -360,6 +371,11 @@ Object.extend(Ajax.Request.prototype, if(typeof(json) == "string")
return Prado.CallbackRequest.decode(json);
}
+ },
+
+ getBodyDataPart : function(name)
+ {
+ return this.getJsonData(this.getBodyContentPart(name));
}
});
@@ -411,6 +427,8 @@ Object.extend(Prado.CallbackRequest, */
PAGESTATE_HEADER : 'X-PRADO-PAGESTATE',
+ REDIRECT_HEADER : 'X-PRADO-REDIRECT',
+
requestQueue : [],
/**
@@ -483,10 +501,13 @@ Object.extend(Prado.CallbackRequest, {
var msg = 'HTTP '+transport.status+" with response : \n";
if(transport.responseText.trim().length >0)
- msg += transport.responseText + "\n";
+ {
+ var f = RegExp('(<!--X-PRADO[^>]+-->)([\\s\\S\\w\\W]*)(<!--//X-PRADO[^>]+-->)',"m");
+ msg += transport.responseText.replace(f,'') + "\n";
+ }
if(typeof(data)!="undefined" && data != null)
msg += "Data : \n"+inspect(data)+"\n";
- data = request.getHeaderData(Prado.CallbackRequest.ACTION_HEADER);
+ data = request.getBodyDataPart(Prado.CallbackRequest.ACTION_HEADER);
if(data && data.length > 0)
{
msg += "Actions : \n";
@@ -591,7 +612,7 @@ Object.extend(Prado.CallbackRequest, var aborted = self.currentRequest == null;
if(enabled && !aborted && pagestate)
{
- var data = request.header(self.PAGESTATE_HEADER);
+ var data = request.getBodyContentPart(self.PAGESTATE_HEADER);
if(typeof(data) == "string" && data.length > 0)
pagestate.value = data;
else
diff --git a/framework/Web/Javascripts/prado/ajax3.js b/framework/Web/Javascripts/prado/ajax3.js index e176aa8a..f6d0823c 100644 --- a/framework/Web/Javascripts/prado/ajax3.js +++ b/framework/Web/Javascripts/prado/ajax3.js @@ -10,12 +10,13 @@ Object.extend(Ajax.Request.prototype, respondToReadyState : function(readyState)
{
var event = Ajax.Request.Events[readyState];
- var transport = this.transport, json = this.getHeaderData(Prado.CallbackRequest.DATA_HEADER);
+ var transport = this.transport, json = this.getBodyDataPart(Prado.CallbackRequest.DATA_HEADER);
if (event == 'Complete')
{
- if(this.header('X-PRADO-REDIRECT'))
- document.location.href = this.header('X-PRADO-REDIRECT');
+ var redirectUrl = this.getBodyContentPart(Prado.CallbackRequest.REDIRECT_HEADER);
+ if(redirectUrl)
+ document.location.href = redirectUrl;
if ((this.header('Content-type') || '').match(/^text\/javascript/i))
{
@@ -33,7 +34,7 @@ Object.extend(Ajax.Request.prototype, {
Prado.CallbackRequest.updatePageState(this,transport);
Ajax.Responders.dispatch('on' + transport.status, this, transport, json);
- Prado.CallbackRequest.dispatchActions(transport,this.getHeaderData(Prado.CallbackRequest.ACTION_HEADER));
+ Prado.CallbackRequest.dispatchActions(transport,this.getBodyDataPart(Prado.CallbackRequest.ACTION_HEADER));
(this.options['on' + this.transport.status]
|| this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
@@ -62,9 +63,19 @@ Object.extend(Ajax.Request.prototype, */
getHeaderData : function(name)
{
+ return this.getJsonData(this.header(name));
+ },
+
+ getBodyContentPart : function(name)
+ {
+ if(typeof(this.transport.responseText)=="string")
+ return Prado.Element.extractContent(this.transport.responseText, name);
+ },
+
+ getJsonData : function(json)
+ {
try
{
- var json = this.header(name);
return eval('(' + json + ')');
}
catch (e)
@@ -72,6 +83,11 @@ Object.extend(Ajax.Request.prototype, if(typeof(json) == "string")
return Prado.CallbackRequest.decode(json);
}
+ },
+
+ getBodyDataPart : function(name)
+ {
+ return this.getJsonData(this.getBodyContentPart(name));
}
});
@@ -123,6 +139,8 @@ Object.extend(Prado.CallbackRequest, */
PAGESTATE_HEADER : 'X-PRADO-PAGESTATE',
+ REDIRECT_HEADER : 'X-PRADO-REDIRECT',
+
requestQueue : [],
/**
@@ -195,10 +213,13 @@ Object.extend(Prado.CallbackRequest, {
var msg = 'HTTP '+transport.status+" with response : \n";
if(transport.responseText.trim().length >0)
- msg += transport.responseText + "\n";
+ {
+ var f = RegExp('(<!--X-PRADO[^>]+-->)([\\s\\S\\w\\W]*)(<!--//X-PRADO[^>]+-->)',"m");
+ msg += transport.responseText.replace(f,'') + "\n";
+ }
if(typeof(data)!="undefined" && data != null)
msg += "Data : \n"+inspect(data)+"\n";
- data = request.getHeaderData(Prado.CallbackRequest.ACTION_HEADER);
+ data = request.getBodyDataPart(Prado.CallbackRequest.ACTION_HEADER);
if(data && data.length > 0)
{
msg += "Actions : \n";
@@ -303,7 +324,7 @@ Object.extend(Prado.CallbackRequest, var aborted = self.currentRequest == null;
if(enabled && !aborted && pagestate)
{
- var data = request.header(self.PAGESTATE_HEADER);
+ var data = request.getBodyContentPart(self.PAGESTATE_HEADER);
if(typeof(data) == "string" && data.length > 0)
pagestate.value = data;
else
diff --git a/framework/Web/Javascripts/prado/element.js b/framework/Web/Javascripts/prado/element.js index 5691e804..0d08a200 100644 --- a/framework/Web/Javascripts/prado/element.js +++ b/framework/Web/Javascripts/prado/element.js @@ -95,8 +95,8 @@ Prado.Element = extractContent : function(text, boundary)
{
- f = RegExp('(<!--'+boundary+'-->)([\\s\\S\\w\\W]*)(<!--//'+boundary+'-->)',"m");
- result = text.match(f);
+ var f = RegExp('(<!--'+boundary+'-->)([\\s\\S\\w\\W]*)(<!--//'+boundary+'-->)',"m");
+ var result = text.match(f);
if(result && result.length >= 2)
return result[2];
else
diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php index 514b6880..8ea196f9 100644 --- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php +++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php @@ -131,7 +131,8 @@ class TActivePageAdapter extends TControlAdapter {
if(!$this->getApplication()->getRequestCompleted())
$this->getApplication()->onEndRequest();
- $this->getResponse()->appendHeader(self::CALLBACK_REDIRECT.': '.$url);
+ $this->appendContentPart($this->getResponse(), self::CALLBACK_REDIRECT, $url);
+ //$this->getResponse()->appendHeader(self::CALLBACK_REDIRECT.': '.$url);
}
/**
@@ -154,7 +155,9 @@ class TActivePageAdapter extends TControlAdapter if(!is_null($responseData))
{
$data = TJavascript::jsonEncode($responseData);
- $response->appendHeader(self::CALLBACK_DATA_HEADER.': '.$data);
+
+ $this->appendContentPart($response, self::CALLBACK_DATA_HEADER, $data);
+ //$response->appendHeader(self::CALLBACK_DATA_HEADER.': '.$data);
}
}
@@ -164,7 +167,8 @@ class TActivePageAdapter extends TControlAdapter if($handler->getActiveControl()->getClientSide()->getEnablePageStateUpdate())
{
$pagestate = $this->getPage()->getClientState();
- $response->appendHeader(self::CALLBACK_PAGESTATE_HEADER.': '.$pagestate);
+ $this->appendContentPart($response, self::CALLBACK_PAGESTATE_HEADER, $pagestate);
+ //$response->appendHeader(self::CALLBACK_PAGESTATE_HEADER.': '.$pagestate);
}
}
@@ -182,8 +186,18 @@ class TActivePageAdapter extends TControlAdapter //output the actions
$executeJavascript = $this->getCallbackClientHandler()->getClientFunctionsToExecute();
$actions = TJavascript::jsonEncode($executeJavascript);
- $response->appendHeader(self::CALLBACK_ACTION_HEADER.': '.$actions);
+ $this->appendContentPart($response, self::CALLBACK_ACTION_HEADER, $actions);
+ //$response->appendHeader(self::CALLBACK_ACTION_HEADER.': '.$actions);
+ }
+ /**
+ * Appends data or javascript code to the body content surrounded with delimiters
+ */
+ private function appendContentPart($response, $delimiter, $data)
+ {
+ $content = $response->createHtmlWriter();
+ $content->getWriter()->setBoundary($delimiter);
+ $content->write($data);
}
/**
diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRedirectionTest.page b/tests/FunctionalTests/active-controls/protected/pages/ActiveRedirectionTest.page new file mode 100644 index 00000000..5f7959c5 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRedirectionTest.page @@ -0,0 +1,8 @@ +<com:TForm>
+<h1>Redirection Test</h1>
+
+<com:TActiveButton Text="Redirect to Default Page" OnClick="button_clicked" />
+
+<com:TJavascriptLogger />
+
+</com:TForm>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/ActiveRedirectionTest.php b/tests/FunctionalTests/active-controls/protected/pages/ActiveRedirectionTest.php new file mode 100644 index 00000000..65958eeb --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/ActiveRedirectionTest.php @@ -0,0 +1,12 @@ +<?php
+
+class ActiveRedirectionTest extends TPage
+{
+ function button_clicked($sender, $param)
+ {
+ $default=$this->Service->constructUrl($this->Service->DefaultPage);
+ $this->Response->redirect($default);
+ }
+}
+
+?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/CustomValidatorByPass.page b/tests/FunctionalTests/active-controls/protected/pages/CustomValidatorByPass.page index 5cacf2ef..068d673c 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/CustomValidatorByPass.page +++ b/tests/FunctionalTests/active-controls/protected/pages/CustomValidatorByPass.page @@ -2,7 +2,7 @@ <h1>Custom Login</h1>
-<com:TActiveLinkButton ID="showLogin" Attributes.OnClick="new Effect.Appear('loginBox')" Text="Login" />
+<a href="#" onclick="new Effect.Appear('loginBox')">Login</a>
<div id="loginBox" style="display: none;">
<div id="loginLoader" style="display: none;">Please Wait...</div>
@@ -28,7 +28,7 @@ <br />
<com:TActiveLinkButton ID="checkLogin" OnCallback="doLogin" Text="Login" ValidationGroup="login" />
- <com:TActiveLinkButton Attributes.OnClick="new Effect.Fade('loginBox')" Text="Close" />
+ <a href="#" onclick="new Effect.Fade('loginBox')">Close</a>
</div>
diff --git a/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest.page b/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest.page new file mode 100644 index 00000000..701bd74c --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest.page @@ -0,0 +1,12 @@ +<com:TForm>
+
+<h1>Large Page State Test</h1>
+
+<com:TActiveButton Text="Show Changes" OnClick="button_clicked"/>
+<com:TActiveLabel ID="status" />
+<com:TJavascriptLogger />
+<com:TPanel ID="Panel1">
+
+</com:TPanel>
+
+</com:TForm>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest.php b/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest.php new file mode 100644 index 00000000..1102ffb2 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest.php @@ -0,0 +1,22 @@ +<?php
+
+class LargePageStateTest extends TPage
+{
+ function onLoad($param)
+ {
+ parent::onLoad($param);
+ for($i=0;$i<100;$i++) //may try 10000, but may crash PHP.
+ {
+ $label = new TLabel();
+ $label->Text=" this is a very long label with some text $i:";
+ $this->Panel1->Controls[] = $label;
+ }
+ }
+
+ function button_clicked($sender, $param)
+ {
+ $this->status->Text .= ' Callback Clicked... ';
+ }
+}
+
+?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest2.page b/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest2.page new file mode 100644 index 00000000..0b662617 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest2.page @@ -0,0 +1,13 @@ +<%@ StatePersisterClass="System.Web.UI.TSessionPageStatePersister" %>
+<com:TForm>
+
+<h1>Large Page State Test (using Session page state)</h1>
+
+<com:TActiveButton Text="Show Changes" OnClick="button_clicked"/>
+<com:TActiveLabel ID="status" />
+<com:TJavascriptLogger />
+<com:TPanel ID="Panel1">
+
+</com:TPanel>
+
+</com:TForm>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest2.php b/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest2.php new file mode 100644 index 00000000..3c3038c2 --- /dev/null +++ b/tests/FunctionalTests/active-controls/protected/pages/LargePageStateTest2.php @@ -0,0 +1,22 @@ +<?php
+
+class LargePageStateTest2 extends TPage
+{
+ function onLoad($param)
+ {
+ parent::onLoad($param);
+ for($i=0;$i<100;$i++) //may try 10000, but may crash PHP.
+ {
+ $label = new TLabel();
+ $label->Text=" this is a very long label with some text $i:";
+ $this->Panel1->Controls[] = $label;
+ }
+ }
+
+ function button_clicked($sender, $param)
+ {
+ $this->status->Text .= ' Callback Clicked... ';
+ }
+}
+
+?>
\ No newline at end of file diff --git a/tests/FunctionalTests/active-controls/protected/pages/TInPlaceTextBoxTest.page b/tests/FunctionalTests/active-controls/protected/pages/TInPlaceTextBoxTest.page index 14f74013..8c0a0d71 100644 --- a/tests/FunctionalTests/active-controls/protected/pages/TInPlaceTextBoxTest.page +++ b/tests/FunctionalTests/active-controls/protected/pages/TInPlaceTextBoxTest.page @@ -1,3 +1,4 @@ +<%@ Application.Globalization.Charset="UTF-8" %>
<com:TForm ID="form1">
<style>
@@ -69,7 +70,7 @@ OnFailure="alert(10)"/>
</com:TInPlaceTextBox>
- <com:TActiveButton Text="ad" OnCallback="NewPackageSubject" ClientSide.OnFailure="alert(10)"/>
+ <com:TActiveButton Text="ad" OnCallback="button_clicked" />
<com:TJavascriptLogger />
|