You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2007/06/09 00:52:31 UTC
svn commit: r545658 - in /tapestry/tapestry4/trunk:
tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
tapestry-framework/src/js/tapestry/core.js
tapestry-framework/src/js/tapestry/form.js
Author: jkuhnert
Date: Fri Jun 8 15:52:30 2007
New Revision: 545658
URL: http://svn.apache.org/viewvc?view=rev&rev=545658
Log:
Fixes TAPESTRY-1549 / TAPESTRY-1548. Refactored and profiled core IO handling javascript client side functions in tapestry. Fixed bug in focusField() for ie6 with trying to call focus() on a select element that isn't currently displayed because of a css "display:none" style attribute.
Modified:
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js
Modified: tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java?view=diff&rev=545658&r1=545657&r2=545658
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java Fri Jun 8 15:52:30 2007
@@ -13,7 +13,6 @@
// limitations under the License.
package org.apache.tapestry.timetracker.page;
-import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.log4j.Logger;
import org.apache.tapestry.annotations.Component;
import org.apache.tapestry.annotations.EventListener;
@@ -106,9 +105,7 @@
@EventListener(events = "onValueChanged", targets = "projectChoose")
public void projectSelected()
{
- getBuilder().updateComponent("projectDescription");
-
- throw new ApplicationRuntimeException("I just made this up. :)");
+ getBuilder().updateComponent("projectDescription");
}
public void showDialog()
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js?view=diff&rev=545658&r1=545657&r2=545658
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js Fri Jun 8 15:52:30 2007
@@ -42,7 +42,8 @@
// The current client side library version, usually matching the current java library version. (ie 4.1, etc..)
version:"4.1.2",
scriptInFlight:false, // whether or not javascript is currently being eval'd, default false
- ScriptFragment:'(?:<script.*?>)((\n|.|\r)*?)(?:<\/script>)', // regexp for script elements
+ ScriptFragment:new RegExp('(?:<script.*?>)((\n|.|\r)*?)(?:<\/script>)', 'im'), // regexp for script elements
+ GlobalScriptFragment:new RegExp('(?:<script.*?>)((\n|.|\r)*?)(?:<\/script>)', 'img'), // regexp for global script fragments
requestsInFlight:0, // how many ajax requests are currently in progress
isIE:dojo.render.html.ie,
@@ -142,19 +143,13 @@
dojo.log.err("Remote server exception received.");
tapestry.presentException(elms[i], kwArgs);
return;
- }
-
- if (elmType == "page") {
- window.location=elms[i].getAttribute("url");
- return;
- }
-
- if (elmType == "status") {
- dojo.event.topic.publish(id,
- {message: tapestry.html.getContentAsString(elms[i])}
- );
- continue;
- }
+ } else if (elmType == "page") {
+ window.location=elms[i].getAttribute("url");
+ return;
+ } else if (elmType == "status") {
+ dojo.event.topic.publish(id, {message: tapestry.html.getContentAsString(elms[i])});
+ continue;
+ }
// handle javascript evaluations
if (elmType == "script") {
@@ -225,17 +220,17 @@
*
*/
loadContent:function(id, node, element){
- if (typeof element.childNodes != "undefined" && element.childNodes.length > 0) {
- for (var i = 0; i < element.childNodes.length; i++) {
- if (element.childNodes[i].nodeType != 1) { continue; }
-
- var nodeId = element.childNodes[i].getAttribute("id");
- if (nodeId) {
- element=element.childNodes[i];
- break;
- }
- }
- }
+ if (typeof element.childNodes != "undefined" && element.childNodes.length > 0) {
+ for (var i = 0; i < element.childNodes.length; i++) {
+ if (element.childNodes[i].nodeType != 1) { continue; }
+
+ var nodeId = element.childNodes[i].getAttribute("id");
+ if (nodeId) {
+ element=element.childNodes[i];
+ break;
+ }
+ }
+ }
dojo.event.browser.clean(node); // prevent mem leaks in ie
@@ -302,36 +297,34 @@
*/
loadScriptContent:function(element, async){
if (typeof async == "undefined") { async = true; }
-
- if (tapestry.scriptInFlight) {
+ async = this.isIE;
+
+ if (tapestry.scriptInFlight) {
dojo.log.debug("loadScriptContent(): scriptInFlight is true, sleeping");
setTimeout(function() { tapestry.loadScriptContent(element, async);}, 5);
return;
}
- var text=tapestry.html.getContentAsString(element);
-
- var match = new RegExp(tapestry.ScriptFragment, 'img');
- var response = text.replace(match, '');
- var scripts = text.match(match);
+ var text=tapestry.html.getContentAsString(element);
+ var response = text.replace(this.GlobalScriptFragment, '');
+ var scripts = text.match(this.GlobalScriptFragment);
if (!scripts) { return; }
- match = new RegExp(tapestry.ScriptFragment, 'im');
if (async) {
setTimeout(function() {
- tapestry.evaluateScripts(scripts, match);
+ tapestry.evaluateScripts(scripts);
}, 60);
} else {
- tapestry.evaluateScripts(scripts, match);
+ tapestry.evaluateScripts(scripts);
}
},
- evaluateScripts:function(scripts, match){
+ evaluateScripts:function(scripts){
tapestry.scriptInFlight = true;
for (var i=0; i<scripts.length; i++) {
- var scr = scripts[i].match(match)[1];
+ var scr = scripts[i].match(this.ScriptFragment)[1];
if(!scr || scr.length <= 0){continue;}
try {
dojo.log.debug("evaluating script:", scr);
@@ -451,8 +444,8 @@
* Provides functionality related to parsing and rendering dom nodes.
*/
tapestry.html={
-
- TextareaMatcher:'<textarea(.*?)/>', // regexp for compact textarea elements
+
+ TextareaRegexp:new RegExp('<textarea(.*?)/>'), // regexp for compact textarea elements
TextareaReplacer:'<textarea$1></textarea>', // replace pattern for compact textareas
/**
@@ -528,17 +521,16 @@
},
_getContentAsStringMozilla:function(node){
- var xmlSerializer = new XMLSerializer();
+ if (!this.xmlSerializer){ this.xmlSerializer = new XMLSerializer();}
+
var s = "";
- for (var i = 0; i < node.childNodes.length; i++) {
- s += xmlSerializer.serializeToString(node.childNodes[i]);
+ for (var i = 0; i < node.childNodes.length; i++) {
+ s += this.xmlSerializer.serializeToString(node.childNodes[i]);
if (s == "undefined")
return this._getContentAsStringGeneric(node);
- }
-
- s = this._processTextareas(s);
-
- return s;
+ }
+
+ return this._processTextareas(s);
},
_getContentAsStringGeneric:function(node){
@@ -564,9 +556,8 @@
_processTextareas:function(htmlData)
{
- var match = new RegExp(tapestry.html.TextareaMatcher);
- while (htmlData.match(match)){
- htmlData = htmlData.replace(match, tapestry.html.TextareaReplacer);
+ while (htmlData.match(this.TextareaRegexp)){
+ htmlData = htmlData.replace(this.TextareaRegexp, this.TextareaReplacer);
}
return htmlData;
}
Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js?view=diff&rev=545658&r1=545657&r2=545658
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/form.js Fri Jun 8 15:52:30 2007
@@ -41,13 +41,12 @@
}
if (!f) { return; }
-
- if(!dj_undef("focus", f)){
- f.focus();
+ if (field.disabled || field.clientWidth < 1) {
return;
}
-
- if (field.disabled || field.clientWidth < 1) {
+
+ if(!dj_undef("focus", f) && dojo.html.isShowing(f)){
+ f.focus();
return;
}