You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2008/03/05 21:55:56 UTC
svn commit: r634025 - in /myfaces/tobago/branches/tobago-1.0.x: ./
theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/
theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/st...
Author: bommel
Date: Wed Mar 5 12:55:54 2008
New Revision: 634025
URL: http://svn.apache.org/viewvc?rev=634025&view=rev
Log:
Merged revisions 634002 via svnmerge from
https://svn.apache.org/repos/asf/myfaces/tobago/trunk
........
r634002 | lofwyr | 2008-03-05 20:52:26 +0100 (Mi, 05 Mär 2008) | 1 line
TOBAGO-630: Better performance for selection of long sheet with IE 6 (and other)
........
Modified:
myfaces/tobago/branches/tobago-1.0.x/ (props changed)
myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
Propchange: myfaces/tobago/branches/tobago-1.0.x/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Mar 5 12:55:54 2008
@@ -1 +1 @@
-/myfaces/tobago/trunk:1-603371,609568-609629,612250-612251,612282,612518,613455,613939,614278,614291,614642,615257,616717,617876,618327,619122,619133,619933,619936,619947-619962,620088,620569,627768-627771,633997,634001
+/myfaces/tobago/trunk:1-603371,609568-609629,612250-612251,612282,612518,613455,613939,614278,614291,614642,615257,616717,617876,618327,619122,619133,619933,619936,619947-619962,620088,620569,627768-627771,633997,634001-634002
Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java?rev=634025&r1=634024&r2=634025&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SheetRenderer.java Wed Mar 5 12:55:54 2008
@@ -61,6 +61,7 @@
import org.apache.myfaces.tobago.ajax.api.AjaxResponseRenderer;
import org.apache.myfaces.tobago.ajax.api.AjaxUtils;
import org.apache.myfaces.tobago.component.ComponentUtil;
+import org.apache.myfaces.tobago.component.UIColumnEvent;
import org.apache.myfaces.tobago.component.UIColumnSelector;
import org.apache.myfaces.tobago.component.UICommand;
import org.apache.myfaces.tobago.component.UIData;
@@ -70,7 +71,6 @@
import org.apache.myfaces.tobago.component.UIMenuCommand;
import org.apache.myfaces.tobago.component.UIPage;
import org.apache.myfaces.tobago.component.UIReload;
-import org.apache.myfaces.tobago.component.UIColumnEvent;
import org.apache.myfaces.tobago.config.TobagoConfig;
import org.apache.myfaces.tobago.context.ResourceManager;
import org.apache.myfaces.tobago.context.ResourceManagerFactory;
@@ -133,6 +133,8 @@
writer.writeStyleAttribute(sheetStyle);
UICommand clickAction = null;
UICommand dblClickAction = null;
+ int columnSelectorIndex = -1;
+ int i = 0;
for (UIComponent child : (List<UIComponent>) data.getChildren()) {
if (child instanceof UIColumnEvent) {
UIColumnEvent columnEvent = (UIColumnEvent) child;
@@ -146,10 +148,12 @@
dblClickAction = action;
}
}
+ } else if (child instanceof UIColumnSelector) {
+ columnSelectorIndex = i;
}
+ i++;
}
-
renderSheet(facesContext, data, (clickAction != null || dblClickAction != null));
writer.endElement(HtmlConstants.DIV);
@@ -172,7 +176,8 @@
}
final String[] cmds = {
"new Tobago.Sheet(\"" + sheetId + "\", " + ajaxEnabled
- + ", \"" + checked + "\", \"" + unchecked + "\", \"" + data.getSelectable() + "\", "+ frequency
+ + ", \"" + checked + "\", \"" + unchecked + "\", \"" + data.getSelectable()
+ + "\", " + columnSelectorIndex + ", "+ frequency
+ ", " + (clickAction!=null?HtmlRendererUtil.getJavascriptString(clickAction.getId()):null)
+ ", " + HtmlRendererUtil.getRenderedPartiallyJavascriptArray(facesContext, clickAction)
+ ", " + (dblClickAction!=null?HtmlRendererUtil.getJavascriptString(dblClickAction.getId()):null)
Modified: myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js?rev=634025&r1=634024&r2=634025&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-sheet.js Wed Mar 5 12:55:54 2008
@@ -40,7 +40,7 @@
};
-Tobago.Sheet = function(sheetId, enableAjax, checkedImage, uncheckedImage, selectable, autoReload,
+Tobago.Sheet = function(sheetId, enableAjax, checkedImage, uncheckedImage, selectable, columnSelectorIndex, autoReload,
clickActionId, clickReloadComponentId, dblClickActionId, dblClickReloadComponentId) {
this.startTime = new Date();
this.id = sheetId;
@@ -49,6 +49,7 @@
this.checkedImage = checkedImage;
this.uncheckedImage = uncheckedImage;
this.selectable = selectable;
+ this.columnSelectorIndex = columnSelectorIndex;
this.autoReload = autoReload;
this.clickActionId = clickActionId;
this.clickReloadComponentId = clickReloadComponentId;
@@ -445,14 +446,13 @@
var row = Tobago.element(this.firstRowId);
if (row) {
var i = this.firstRowIndex;
- i++;
while (row) {
// LOG.debug("rowId = " + row.id + " next i=" + i);
Tobago.addBindEventListener(row, "click", this, "doSelection");
if (this.dblClickActionId) {
Tobago.addBindEventListener(row, "dblclick", this, "doDblClick");
}
- row = Tobago.element(this.id + "_data_tr_" + i++ );
+ row = this.getSiblingRow(row, ++i)
}
//LOG.debug("preSelected rows = " + Tobago.element(sheetId + "::selected").value);
}
@@ -556,34 +556,50 @@
}
};
+Tobago.Sheet.prototype.getSelectionElementForRow = function(row) {
+ if (this.columnSelectorIndex >= 0) {
+ return row.childNodes[this.columnSelectorIndex].childNodes[0].childNodes[0].childNodes[0];
+ }
+};
+
+Tobago.Sheet.prototype.getSiblingRow = function(row, i) {
+ return row.parentNode.childNodes[i];
+};
+
Tobago.Sheet.prototype.updateSelectionView = function(sheetId) {
- var selected = Tobago.element(this.selectedId).value;
- var row = Tobago.element(this.firstRowId);
- var i = this.firstRowIndex;
- while (row) {
+ var selected = Tobago.element(this.selectedId).value;
+ var row = Tobago.element(this.firstRowId);
+ var i = 0;
- var selector = Tobago.element(this.id + "_data_row_selector_" + i);
- var re = new RegExp("," + i +",");
- var classes = row.className;
- var img = Tobago.element(this.id + "_data_row_selector_" + i);
- if (selected.search(re) == -1) { // not selected: remove selection class
- Tobago.removeCssClass(row, "tobago-sheet-row-selected");
+ while (row) {
- if (img && (!selector || !selector.src.match(/Disabled/))) {
- img.src = this.uncheckedImage;
- }
+ // you must not use Tobago.element() or document.getElementById() because the IE 6? doen't index the ids.
+ // to the performace is quadratic aka. O(N*N) when N is the number of rows.
+
+ var rowIndex = i + this.firstRowIndex * 1; // * 1 to keep integer operation
+ var re = new RegExp("," + rowIndex + ",");
+ var classes = row.className;
+ var image = this.getSelectionElementForRow(row);
+
+ if (selected.search(re) == -1) { // not selected: remove selection class
+
+ Tobago.removeCssClass(row, "tobago-sheet-row-selected");
+
+ if (image && !image.src.match(/Disabled/)) {
+ image.src = this.uncheckedImage;
}
- else { // selected: check selection class
- if (classes.search(/tobago-sheet-row-selected/) == -1) {
- Tobago.addCssClass(row, "tobago-sheet-row-selected");
- }
- if (img && (!selector || !selector.src.match(/Disabled/))) {
- img.src = this.checkedImage;
- }
+
+ } else { // selected: check selection class
+ if (classes.search(/tobago-sheet-row-selected/) == -1) {
+ Tobago.addCssClass(row, "tobago-sheet-row-selected");
+ }
+ if (image && !image.src.match(/Disabled/)) {
+ image.src = this.checkedImage;
}
- row = Tobago.element(this.id + "_data_tr_" + ++i );
}
- };
+ row = this.getSiblingRow(row, ++i);
+ }
+};
Tobago.Sheet.prototype.toggleSelectionForRow = function(dataRow) {
var rowIndex = dataRow.id.substring(dataRow.id.lastIndexOf("_data_tr_") + 9);
@@ -591,8 +607,7 @@
};
Tobago.Sheet.prototype.toggleSelection = function(rowIndex) {
- this.tobagoLastClickedRowId
- = Tobago.element(this.id + "_data_tr_" + rowIndex).id;
+ this.tobagoLastClickedRowId = Tobago.element(this.id + "_data_tr_" + rowIndex).id;
var selector = Tobago.element(this.id + "_data_row_selector_" + rowIndex);
if (!selector || !selector.src.match(/Disabled/)) {
var re = new RegExp("," + rowIndex + ",");
@@ -812,14 +827,14 @@
var i = this.firstRowIndex;
var selected = Tobago.element(this.selectedId);
while (row) {
- var selector = Tobago.element(this.id + "_data_row_selector_" + i);
- if (!selector || !selector.src.match(/Disabled/)) {
+ var image = this.getSelectionElementForRow(row);
+ if (!image || !image.src.match(/Disabled/)) {
var re = new RegExp("," + i + ",");
if (selected.value.search(re) == -1) {
selected.value = selected.value + "," + i + ",";
}
}
- row = Tobago.element(this.id + "_data_tr_" + ++i );
+ row = this.getSiblingRow(row, ++i);
}
this.updateSelectionView();
};
@@ -827,16 +842,16 @@
Tobago.Sheet.prototype.unSelectAll = function() {
var selected = Tobago.element(this.selectedId);
var row = Tobago.element(this.firstRowId);
- var selector = Tobago.element(this.id + "_data_row_selector_" + i);
- if (selector) {
+ var image = this.getSelectionElementForRow(row);
+ if (image) {
var i = this.firstRowIndex;
while (row) {
- selector = Tobago.element(this.id + "_data_row_selector_" + i);
- if (!selector || !selector.src.match(/Disabled/)) {
+ image = this.getSelectionElementForRow(row);
+ if (!image || !image.src.match(/Disabled/)) {
var re = new RegExp("," + i + ",", 'g');
selected.value = selected.value.replace(re, "");
}
- row = Tobago.element(this.id + "_data_tr_" + ++i );
+ row = this.getSiblingRow(row, ++i);
}
} else {
selected.value = "";
@@ -849,8 +864,7 @@
var i = this.firstRowIndex;
while (row) {
this.toggleSelection(i);
- row = Tobago.element(this.id + "_data_tr_" + ++i );
+ row = this.getSiblingRow(row, ++i);
}
this.updateSelectionView();
};
-