JBoss Rich Faces SVN: r1329 - in trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI: controls/grid and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: dmorozov
Date: 2007-06-26 13:26:16 -0400 (Tue, 26 Jun 2007)
New Revision: 1329
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/box/Box.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js
Log:
Remove getElementByClassName method usage
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/box/Box.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/box/Box.js 2007-06-26 16:25:12 UTC (rev 1328)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/common/box/Box.js 2007-06-26 17:26:16 UTC (rev 1329)
@@ -81,8 +81,10 @@
return this.element;
},
getHeight: function() {
- if(this.getElement().tagName.toLowerCase() != "body")
- return Element.getHeight(this.element);
+ if(this.getElement().tagName.toLowerCase() != "body") {
+ var h = Element.getHeight(this.element);
+ return h>0 ? h : (this.element.boxHeight ? parseInt(this.element.boxHeight) : 0);
+ }
if (self.innerHeight) { // all except Explorer
return self.innerHeight;
@@ -97,6 +99,7 @@
},
isModified: false,
setHeight: function(newHeight) {
+ this.element.boxHeight = newHeight;
if(Validators.IsNumber(newHeight)) {
if(newHeight<0) newHeight = 0;
newHeight += "px";
@@ -106,8 +109,10 @@
return this;
},
getWidth: function() {
- if(this.getElement().tagName.toLowerCase() != "body")
- return Element.getWidth(this.element);
+ if(this.getElement().tagName.toLowerCase() != "body") {
+ var w = Element.getWidth(this.element);
+ return w>0 ? w : (this.element.boxWidth ? parseInt(this.element.boxWidth) : 0);
+ }
if (self.innerHeight) {// all except Explorer
return self.innerWidth;
@@ -121,6 +126,7 @@
}
},
setWidth: function(newWidth) {
+ this.element.boxWidth = newWidth;
if(Validators.IsNumber(newWidth)) {
if(newWidth<0) newWidth = 0;
newWidth += "px";
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js 2007-06-26 16:25:12 UTC (rev 1328)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid.js 2007-06-26 17:26:16 UTC (rev 1329)
@@ -64,28 +64,29 @@
},
createControl: function() {
var grid = this;
- var layout = new ClientUI.layouts.GridLayoutManager(null, this.getElement());
- this.layout = layout;
- var header, body, footer;
- this.templates.unbreakableEach(function(item) {
+ this.layout = new ClientUI.layouts.GridLayoutManager(null, this.getElement());
+
+ var pagePart, item;
+ for(var i=0; i<this.templates.length; i++) {
+ item = this.templates[i];
switch(item.pane) {
case GridLayout_Enum.HEADER: {
- header = new ClientUI.controls.grid.GridHeader($(item.ref), grid);
- layout.addPane(GridLayout_Enum.HEADER, header);
+ pagePart = new ClientUI.controls.grid.GridHeader($(item.ref), grid);
+ this.layout.addPane(GridLayout_Enum.HEADER, pagePart);
break;
}
case GridLayout_Enum.BODY: {
- body = new ClientUI.controls.grid.GridBody($(item.ref), grid);
- layout.addPane(GridLayout_Enum.BODY, body);
+ pagePart = new ClientUI.controls.grid.GridBody($(item.ref), grid);
+ this.layout.addPane(GridLayout_Enum.BODY, pagePart);
break;
}
case GridLayout_Enum.FOOTER: {
- footer = new ClientUI.controls.grid.GridFooter($(item.ref), grid);
- layout.addPane(GridLayout_Enum.FOOTER, footer);
+ pagePart = new ClientUI.controls.grid.GridFooter($(item.ref), grid);
+ this.layout.addPane(GridLayout_Enum.FOOTER, pagePart);
break;
}
- }
- });
+ }
+ }
this.currentScrollPos = 0;
this.controlCreated = true;
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-06-26 16:25:12 UTC (rev 1328)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody.js 2007-06-26 17:26:16 UTC (rev 1329)
@@ -53,7 +53,6 @@
this.createControl(template);
this.registerEvents();
- this.updateLayout();
},
registerEvents: function() {
Event.observe(this.scrollBox.eventHScroll, "grid body hscroll", this._eventOnHScroll);
@@ -177,17 +176,17 @@
}
var columns = this.grid.getHeader().getColumns();
- var i=0;
- var cols = $A(this.templFrozen.getElement().getElementsByTagName("col"));
- cols.each(function(col) {
- columns[i].bodyCol = $(col);
- i++;
- });
- cols = $A(this.templNormal.getElement().getElementsByTagName("col"));
- cols.each(function(col) {
- columns[i].bodyCol = $(col);
- i++;
- });
+ var i=0, j=0;
+ var cols = this.templFrozen.getElement().getElementsByTagName("col");
+ for(i=0; i<cols.length; i++) {
+ columns[j].bodyCol = $(cols[i]);
+ j++;
+ }
+ cols = this.templNormal.getElement().getElementsByTagName("col");
+ for(i=0; i<cols.length; i++) {
+ columns[j].bodyCol = $(cols[i]);
+ j++;
+ }
this.rowsCount = Math.min(templNormal.rows.length, this.grid.dataModel.getCount());
var cell = templNormal.rows[0].cells[0];
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter.js 2007-06-26 16:25:12 UTC (rev 1328)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter.js 2007-06-26 17:26:16 UTC (rev 1329)
@@ -43,7 +43,6 @@
this.setHeight(this.defaultHeight);
this.setWidth(this.defaultWidth);
this.controlCreated = true;
- this.updateLayout();
},
parseTemplate: function(template) {
if(!template) {
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js 2007-06-26 16:25:12 UTC (rev 1328)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js 2007-06-26 17:26:16 UTC (rev 1329)
@@ -62,7 +62,6 @@
this.setHeight(this.defaultHeight);
this.setWidth(this.defaultWidth);
this.controlCreated = true;
- this.updateLayout();
},
parseTemplate: function(template) {
if(!template) {
@@ -119,23 +118,26 @@
this.helpObj = new ClientUI.common.box.Box(this.frozenContentBox.getElement(), null, true);
- var columns = [];
+ var fcount = this.headerFrozenRow.getElement().rows[0].cells.length;
+ var ncount = this.headerRow.getElement().rows[0].cells.length;
+ var columns = new Array(fcount + ncount);
var defaultWidth = 0;
var defaultHeight = 0;
var eventCellMouseDown = this.eventCellMouseDown.bind(this);
// Get columns information
- var i = 0, h, j=0;
- var cols = $A(this.headerFrozenRow.getElement().getElementsByTagName("col"));
- var cells = $A(this.headerFrozenRow.getElement().rows[0].cells);
- var ids = this.grid.options.ids;
- cells.each(function(cell) {
- columns[i] = {
+ var i = 0, h, j=0, cell;
+ var cols = this.headerFrozenRow.getElement().getElementsByTagName("col");
+ var cells = this.headerFrozenRow.getElement().rows[0].cells;
+ var ids = this.grid.options.ids;
+ var count = cells.length;
+ for(i=0; i<count; i++) {
+ cell = cells[i];
+ columns[j] = {
columnId: ids[i],
- col: $(cols[j]),
- width: parseInt(cols[j].width), //Element.getWidth(cell),
- innerHTML: cell.innerHTML,
+ col: cols[i],
+ width: parseInt(cols[i].width),
styleClass: cell.className,
id: cell.id,
align: cell.align,
@@ -148,30 +150,44 @@
sorted: Validators.getBoolean(cell.getAttribute("sorted"), "desc")
};
- if(columns[i].sortable)
+ if(columns[j].sortable)
Event.observe(cell, 'click', eventCellMouseDown);
h = Element.getHeight(cell);
if(h > defaultHeight) defaultHeight = h;
- defaultWidth += columns[i].width;
- columns[i].object = new ClientUI.common.box.InlineBox(cell, null, true);
- columns[i].sortDesc = document.getElementsByClassName("sort-desc", cell)[0];
- columns[i].sortAsc = document.getElementsByClassName("sort-asc", cell)[0];
- if(ClientUILib.isIE && columns[i].sortDesc) {
- Element.setStyle(columns[i].sortDesc, {left: "-10px"});
- Element.setStyle(columns[i].sortAsc, {left: "-10px"});
+ defaultWidth += columns[j].width;
+ columns[j].object = new ClientUI.common.box.InlineBox(cell, null, true);
+
+ var details = this._getCellElements(cell);
+ // separator
+ columns[j].sep = new ClientUI.common.box.InlineBox(details[0], null, true);
+ columns[j].sep.getElement().columnIndex = j;
+ if(!columns[j].fixedWidth) {
+ Event.observe(columns[j].sep.getElement(), 'dblclick', this.eventSepDblClick);
+ Event.observe(columns[j].sep.getElement(), 'mousedown', this.eventSepMouseDown);
+ }
+ else {
+ sep.setStyle({cursor: 'auto'});
}
- i++;j++;
- });
+ // sort icons
+ columns[j].sortDesc = details[1];
+ columns[j].sortAsc = details[2];
+ if(ClientUILib.isIE && columns[j].sortDesc) {
+ Element.setStyle(columns[j].sortDesc, {left: "-10px"});
+ Element.setStyle(columns[j].sortAsc, {left: "-10px"});
+ }
+ j++;
+ }
- j=0;
- cols = $A(this.headerRow.getElement().getElementsByTagName("col"));
- cells = $A(this.headerRow.getElement().rows[0].cells);
- cells.each(function(cell) {
- columns[i] = {
+ cols = this.headerRow.getElement().getElementsByTagName("col");
+ cells = this.headerRow.getElement().rows[0].cells;
+ count = cells.length;
+ for(i=0; i<count; i++) {
+ cell = cells[i];
+
+ columns[j] = {
columnId: ids[i],
- col: $(cols[j]),
- width: parseInt(cols[j].width), //Element.getWidth(cell),
- innerHTML: cell.innerHTML,
+ col: cols[i],
+ width: parseInt(cols[i].width),
styleClass: cell.className,
id: cell.id,
align: cell.align,
@@ -184,20 +200,33 @@
sorted: Validators.getBoolean(cell.getAttribute("sorted"), "desc")
};
- if(columns[i].sortable)
+ if(columns[j].sortable)
Event.observe(cell, 'click', eventCellMouseDown);
h = Element.getHeight(cell);
if(h > defaultHeight) defaultHeight = h;
- defaultWidth += columns[i].width;
- columns[i].object = new ClientUI.common.box.InlineBox(cell, null, true);
- columns[i].sortDesc = document.getElementsByClassName("sort-desc", cell)[0];
- columns[i].sortAsc = document.getElementsByClassName("sort-asc", cell)[0];
- if(ClientUILib.isIE && columns[i].sortDesc) {
- Element.setStyle(columns[i].sortDesc, {left: "-10px"});
- Element.setStyle(columns[i].sortAsc, {left: "-10px"});
+ defaultWidth += columns[j].width;
+ columns[j].object = new ClientUI.common.box.InlineBox(cell, null, true);
+
+ var details = this._getCellElements(cell);
+ // separator
+ columns[j].sep = new ClientUI.common.box.InlineBox(details[0], null, true);
+ columns[j].sep.getElement().columnIndex = j;
+ if(!columns[j].fixedWidth) {
+ Event.observe(columns[j].sep.getElement(), 'dblclick', this.eventSepDblClick);
+ Event.observe(columns[j].sep.getElement(), 'mousedown', this.eventSepMouseDown);
+ }
+ else {
+ sep.setStyle({cursor: 'auto'});
}
- i++;j++;
- });
+ // sort icons
+ columns[j].sortDesc = details[1];
+ columns[j].sortAsc = details[2];
+ if(ClientUILib.isIE && columns[j].sortDesc) {
+ Element.setStyle(columns[j].sortDesc, {left: "-10px"});
+ Element.setStyle(columns[j].sortAsc, {left: "-10px"});
+ }
+ j++;
+ }
this._columns = columns;
this.defaultHeight = defaultHeight;
@@ -207,21 +236,6 @@
this.defaultHeight -= this.getBorderWidth("tb") + this.getPadding("tb");
}
- var sep, column;
- var seps = document.getElementsByClassName("ClientUI_Grid_HSep", this.getElement());
- for(i = 0; i<seps.length; i++) {
- sep = seps[i];
- column = parseInt(sep.getAttribute("column"));
- this._columns[column].sep = new ClientUI.common.box.InlineBox(sep, null, true);
- sep.columnIndex = column;
- if(!this._columns[column].fixedWidth) {
- Event.observe(sep, 'dblclick', this.eventSepDblClick);
- Event.observe(sep, 'mousedown', this.eventSepMouseDown);
- }
- else {
- sep.setStyle({cursor: 'auto'});
- }
- }
this.agjustSeparators();
if(ClientUILib.isIE) {
@@ -233,6 +247,28 @@
return true;
},
+ _getCellElements: function(cell) {
+ var details = new Array(3);
+ var spans = cell.getElementsByTagName("span");
+ var count = spans ? spans.length : 0;
+ var el, className;
+ for(var i=0; i<count; i++) {
+ el = spans[i];
+ className = el.className;
+ if(className && className.length>0) {
+ if(className.indexOf("ClientUI_Grid_HSep")>=0) {
+ details[0] = el;
+ }
+ else if(className.indexOf("sort-desc")>=0) {
+ details[1] = el;
+ }
+ else if(className.indexOf("sort-asc")>=0) {
+ details[2] = el;
+ }
+ }
+ }
+ return details;
+ },
agjustSeparators: function() {
var offset = 0;
var fcnt = this.headerFrozenRow.getElement().rows[0].cells.length;
17 years, 6 months
JBoss Rich Faces SVN: r1328 - trunk/richfaces-samples/tree-demo/src/main/java/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-06-26 12:25:12 -0400 (Tue, 26 Jun 2007)
New Revision: 1328
Removed:
trunk/richfaces-samples/tree-demo/src/main/java/org/richfaces/CachingTreeDataLocator.java
Log:
CachingTreeDataLocator.java removed
Deleted: trunk/richfaces-samples/tree-demo/src/main/java/org/richfaces/CachingTreeDataLocator.java
===================================================================
--- trunk/richfaces-samples/tree-demo/src/main/java/org/richfaces/CachingTreeDataLocator.java 2007-06-26 16:14:55 UTC (rev 1327)
+++ trunk/richfaces-samples/tree-demo/src/main/java/org/richfaces/CachingTreeDataLocator.java 2007-06-26 16:25:12 UTC (rev 1328)
@@ -1,83 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.richfaces.component.TreeRowKey;
-import org.richfaces.component.preserve.TreeDataLocator;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 30.12.2006
- *
- */
-public class CachingTreeDataLocator implements TreeDataLocator {
-
- private static class CacheEntry {
- private int pid;
- private TreeRowKey key;
- private Object data;
- }
-
- private List cache = new ArrayList();
- private int number = 0;
-
- /* (non-Javadoc)
- * @see com.exadel.jsf.model.preserve.TreeDataLocator#createData(java.lang.Object, com.exadel.jsf.model.TreeRowKey, com.exadel.jsf.model.TreeNode)
- */
- public Object createData(Object locator, TreeRowKey rowKey) {
- for (Iterator iterator = cache.iterator(); iterator.hasNext();) {
- CacheEntry entry = (CacheEntry) iterator.next();
- if (entry.pid == ((Integer) locator).intValue()) {
- return entry.data;
- }
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see com.exadel.jsf.model.preserve.TreeDataLocator#createLocator(java.lang.Object, com.exadel.jsf.model.TreeRowKey, com.exadel.jsf.model.TreeNode)
- */
- public Object createLocator(Object data, TreeRowKey rowKey) {
- for (Iterator iterator = cache.iterator(); iterator.hasNext();) {
- CacheEntry entry = (CacheEntry) iterator.next();
-
- if (entry.key.equals(rowKey)) {
- return Integer.valueOf(entry.pid);
- }
- }
-
- CacheEntry cacheEntry = new CacheEntry();
- cacheEntry.data = data;
- cacheEntry.key = rowKey;
- cacheEntry.pid = number++;
-
- cache.add(cacheEntry);
-
- return Integer.valueOf(cacheEntry.pid);
- }
-
-}
17 years, 6 months
JBoss Rich Faces SVN: r1327 - in trunk/richfaces/tree/src: main/java/org/richfaces/component/preserve and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-06-26 12:14:55 -0400 (Tue, 26 Jun 2007)
New Revision: 1327
Removed:
trunk/richfaces/tree/src/main/java/org/richfaces/component/preserve/TreeDataBatchLocator.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/preserve/TreeDataLocator.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/preserve/TreeNodeInfo.java
Modified:
trunk/richfaces/tree/src/main/java/org/richfaces/component/AbstractTreeDataModel.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/TreeDataModel.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/state/TreeState.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/CollapseAllCommandEvent.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/CollapseNodeCommandEvent.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/ExpandAllCommandEvent.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/ExpandNodeCommandEvent.java
trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/TreeStateCommandsListener.java
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeDataModelEventNavigator.java
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/MockTreeStateCommandsListener.java
Log:
- Tree refactored to use more generic parameters
- Handling for UITreeNode "rendered" attribute added
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/AbstractTreeDataModel.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/AbstractTreeDataModel.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/AbstractTreeDataModel.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -81,7 +81,7 @@
* @see {@link ExtendedDataModel#walk(FacesContext, DataVisitor, Range, Object)}
*/
public abstract void walk(FacesContext context, DataVisitor dataVisitor,
- Range range, TreeRowKey rowKey, Object argument, boolean last) throws IOException;
+ Range range, Object rowKey, Object argument, boolean last) throws IOException;
/**
* returns whether this node is leaf
@@ -91,17 +91,17 @@
/**
* Walk backing sub-model having row key argument as its root. If there is no backing model
- * configured, calling this method is equivalent to calling {@link #walk(FacesContext, DataVisitor, Range, TreeRowKey, Object, boolean)}
+ * configured, calling this method is equivalent to calling {@link #walk(FacesContext, DataVisitor, Range, Object, Object, boolean)}
* @param facesContext faces context
* @param visitor {@link UIDataAdaptor.ComponentVisitor} instance
- * @param range {@link TreeRange} to constraint the walk
+ * @param range {@link Range} to constraint the walk
* @param key row key to treat as root of sub-model
* @param argument implementation-specific argument
* @throws IOException
*
* @see {@link #walk(FacesContext, DataVisitor, Range, TreeRowKey, Object, boolean)}
*/
- public abstract void walkModel(FacesContext facesContext, DataVisitor visitor, TreeRange range, TreeRowKey key, Object argument, boolean last) throws IOException;
+ public abstract void walkModel(FacesContext facesContext, DataVisitor visitor, Range range, Object key, Object argument, boolean last) throws IOException;
/**
* Processes concrete tree node. Knows about {@link LastElementAware} interface and handles it
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/CacheableTreeDataModel.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -22,20 +22,17 @@
package org.richfaces.component;
import java.io.IOException;
-import java.util.Iterator;
-import javax.faces.component.StateHolder;
import javax.faces.context.FacesContext;
import org.ajax4jsf.ajax.repeat.DataVisitor;
import org.ajax4jsf.ajax.repeat.Range;
-import org.richfaces.component.state.TreeRange;
/**
* @author Nick - mailto:nbelaevski@exadel.com created 08.01.2007
*
*/
-public class CacheableTreeDataModel extends TreeDataModel implements StateHolder{
+public class CacheableTreeDataModel extends TreeDataModel {
private final class Visitor implements DataVisitor, LastElementAware {
private final DataVisitor visitor;
@@ -94,7 +91,7 @@
}
public void walkModel(FacesContext context, DataVisitor visitor,
- TreeRange range, TreeRowKey key, Object argument, boolean last)
+ Range range, Object key, Object argument, boolean last)
throws IOException {
treeDataModel.walkModel(context, new Visitor(visitor), range, key,
argument, last);
@@ -109,11 +106,11 @@
}
public void walk(FacesContext context, final DataVisitor dataVisitor,
- Range range, TreeRowKey rowKey, Object argument, boolean last)
+ Range range, Object rowKey, Object argument, boolean last)
throws IOException {
- TreeNode cachedTreeNode = locateTreeNode(rowKey);
- TreeNode treeNode = treeDataModel.locateTreeNode(rowKey);
+ TreeNode cachedTreeNode = locateTreeNode((TreeRowKey) rowKey);
+ TreeNode treeNode = treeDataModel.locateTreeNode((TreeRowKey) rowKey);
if (treeNode != null) {
if (cachedTreeNode == null || (cachedTreeNode.isLeaf() && !treeNode.isLeaf())) {
@@ -124,7 +121,6 @@
super.walk(context, dataVisitor, range, rowKey, argument, last);
}
}
-
}
public void setRowData(Object object) {
@@ -132,32 +128,13 @@
}
public boolean isTransient() {
- return false;
+ return true;
}
- public void restoreState(FacesContext context, Object state) {
- Object[] _state = (Object[]) state;
- setWrappedData(_state[0]);
- }
-
- public Object saveState(FacesContext context) {
- Object[] state = new Object[1];
- state[0] = getWrappedData();
- return state;
- }
-
public void setTransient(boolean newTransientValue) {
- if (newTransientValue) {
+ if (!newTransientValue) {
throw new IllegalArgumentException(
"ReplaceableTreeDataModel shouldn't be transient!");
}
}
-
- public void resetSub(TreeRowKey key) {
- TreeNode node = locateTreeNode(key);
- for (Iterator iterator = node.getChildren(); iterator.hasNext();) {
- iterator.next();
- iterator.remove();
- }
- }
}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/TreeDataModel.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/TreeDataModel.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/TreeDataModel.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -59,7 +59,7 @@
public void walk(FacesContext context, DataVisitor dataVisitor,
- Range range, TreeRowKey rowKey, Object argument, boolean last) throws IOException {
+ Range range, Object rowKey, Object argument, boolean last) throws IOException {
ListRowKey listRowKey = (ListRowKey) rowKey;
@@ -68,13 +68,13 @@
if (node != null) {
TreeRange treeRange = (TreeRange) range;
- if (treeRange == null || treeRange.processNode(rowKey)) {
+ if (treeRange == null || treeRange.processNode(listRowKey)) {
if (node.getParent() != null) {
- processElement(context, dataVisitor, argument, rowKey, last);
+ processElement(context, dataVisitor, argument, listRowKey, last);
}
- if (treeRange == null || treeRange.processChildren(rowKey)) {
+ if (treeRange == null || treeRange.processChildren(listRowKey)) {
if (!node.isLeaf()) {
Iterator children = node.getChildren();
@@ -213,7 +213,7 @@
"No tree element available or row key not set!");
}
- public void walkModel(FacesContext context, DataVisitor visitor, TreeRange range, TreeRowKey key, Object argument, boolean last) throws IOException {
+ public void walkModel(FacesContext context, DataVisitor visitor, Range range, Object key, Object argument, boolean last) throws IOException {
walk(context, visitor, range, key, argument, last);
}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/UITree.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -24,7 +24,6 @@
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
import javax.faces.application.Application;
import javax.faces.component.NamingContainer;
@@ -39,6 +38,7 @@
import org.ajax4jsf.ajax.repeat.DataComponentState;
import org.ajax4jsf.ajax.repeat.DataVisitor;
import org.ajax4jsf.ajax.repeat.ExtendedDataModel;
+import org.ajax4jsf.ajax.repeat.Range;
import org.ajax4jsf.ajax.repeat.UIDataAdaptor;
import org.ajax4jsf.dnd.Draggable;
import org.ajax4jsf.dnd.Dropzone;
@@ -93,8 +93,6 @@
public static final String SELECTION_INPUT_ATTRIBUTE = "_selectionInput";
- public final static String TREE_DATA_LOCATOR_BINDING = "treeDataLocator";
-
public final static String DEFAULT_SELECTED_CSS_CLASS = "dr-tree-i-sel";
public final static String DEFAULT_HIGHLIGHTED_CSS_CLASS = "dr-tree-i-hl";
@@ -238,28 +236,12 @@
super.resetDataModel();
TreeState state = (TreeState) getComponentState();
-
- CacheableTreeDataModel cacheableModel = state.getTreeDataModel();
- if (cacheableModel != null) {
- if (cacheableModel.isTransient()) {
- state.setTreeDataModel(null);
- setExtendedDataModel(createDataModel(false));
- } else {
- Set ajaxKeys = getAjaxKeys();
- for (Iterator iterator = ajaxKeys.iterator(); iterator
- .hasNext();) {
- TreeRowKey treeRowKey = (TreeRowKey) iterator.next();
-
- cacheableModel.resetSub(treeRowKey);
- }
- }
- }
-
-
// transfer nodes delayed to open to rendering queue
state.transferQueuedNodes();
// re-set stopInCollapsed to handle AJAX switch type change
state.setStopInCollapsed(isStopInCollapsed());
+
+ setExtendedDataModel(createDataModel(false));
}
public void walk(FacesContext faces, DataVisitor visitor)
@@ -275,21 +257,23 @@
* {@link FacesContext} instance
* @param visitor
* {@link UIDataAdaptor.ComponentVisitor} instance
+ * @param range
+ * {@link Range} range instance
* @param rowKey
- * {@link TreeRowKey} instance to start from or null to start
+ * row key to start from or null to start
* from root
* @param argument
* implementation-specific visitor argument
* @throws IOException
*/
- public void walk(FacesContext faces, DataVisitor visitor,
- TreeRowKey rowKey, Object argument) throws IOException {
+ public void walk(FacesContext faces, DataVisitor visitor, Range range,
+ Object rowKey, Object argument) throws IOException {
Object savedRowKey = getRowKey();
try {
AbstractTreeDataModel dataModel = (AbstractTreeDataModel) getExtendedDataModel();
- dataModel.walk(faces, visitor, getComponentState().getRange(), rowKey,
+ dataModel.walk(faces, visitor, range, rowKey,
argument,
faces.getExternalContext().getRequestParameterMap().get(
getBaseClientId(faces) + LAST_ELEMENT_FLAG) != null);
@@ -307,18 +291,20 @@
* {@link FacesContext} instance
* @param visitor
* {@link UIDataAdaptor.ComponentVisitor} instance
+ * @param range
+ * {@link Range} range instance
* @param rowKey
- * {@link TreeRowKey} instance to start from or null to start
+ * row key to start from or null to start
* from root
* @param argument
* implementation-specific visitor argument
* @throws IOException
*/
- public void walkModel(FacesContext faces, DataVisitor visitor,
- TreeRowKey key, Object argument) throws IOException {
+ public void walkModel(FacesContext faces, DataVisitor visitor, Range range,
+ Object key, Object argument) throws IOException {
AbstractTreeDataModel extendedDataModel = (AbstractTreeDataModel) getExtendedDataModel();
extendedDataModel.walkModel(faces, visitor,
- (TreeRange) getComponentState().getRange(), key, argument,
+ (TreeRange) range, key, argument,
faces.getExternalContext().getRequestParameterMap().get(
getBaseClientId(faces) + LAST_ELEMENT_FLAG) != null);
}
@@ -420,7 +406,7 @@
protected DataComponentState createComponentState() {
- return new TreeState(this, isStopInCollapsed());
+ return new TreeState(isStopInCollapsed());
}
/**
@@ -459,33 +445,24 @@
return isAjaxSubmitSelection();
}
- private ExtendedDataModel createDataModel(boolean allowTransientModel) {
- TreeState state = ((TreeState) getComponentState());
- CacheableTreeDataModel stateModel = state.getTreeDataModel();
-
+ private ExtendedDataModel createDataModel(boolean allowCached) {
TreeDataModel treeDataModel = new TreeDataModel();
treeDataModel.setWrappedData(this.getValue());
+
+ if (allowCached && PRESERVE_MODEL_REQUEST.equals(getPreserveModel())) {
+ treeDataModel = new CacheableTreeDataModel(treeDataModel);
+ }
- if (stateModel == null) {
- String preserveModel = getPreserveModel();
- if (allowTransientModel && PRESERVE_MODEL_REQUEST.equals(preserveModel)) {
- stateModel = new CacheableTreeRequestDataModel(treeDataModel);
- state.setTreeDataModel(stateModel);
- } else if (PRESERVE_MODEL_STATE.equals(preserveModel)) {
- stateModel = new CacheableTreeDataModel(treeDataModel);
- state.setTreeDataModel(stateModel);
- } else {
- return treeDataModel;
- }
- } else {
- //bind existing model to the state-saved model
- stateModel.setTreeDataModel(treeDataModel);
+ return treeDataModel;
+ }
+
+ public void processUpdates(FacesContext faces) {
+ super.processUpdates(faces);
+ if (getExtendedDataModel() instanceof CacheableTreeDataModel) {
+ setExtendedDataModel(createDataModel(false));
}
-
- return stateModel;
}
-
protected ExtendedDataModel createDataModel() {
return createDataModel(true);
}
Deleted: trunk/richfaces/tree/src/main/java/org/richfaces/component/preserve/TreeDataBatchLocator.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/preserve/TreeDataBatchLocator.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/preserve/TreeDataBatchLocator.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -1,34 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.preserve;
-
-import org.richfaces.component.TreeRowKey;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 30.12.2006
- *
- */
-public interface TreeDataBatchLocator {
- public Object[] createLocator(Object[] data, TreeRowKey rowKey);
- public Object[] createData(Object[] locator, TreeRowKey rowKey);
-}
Deleted: trunk/richfaces/tree/src/main/java/org/richfaces/component/preserve/TreeDataLocator.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/preserve/TreeDataLocator.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/preserve/TreeDataLocator.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -1,34 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.preserve;
-
-import org.richfaces.component.TreeRowKey;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 30.12.2006
- *
- */
-public interface TreeDataLocator {
- public Object createLocator(Object data, TreeRowKey rowKey);
- public Object createData(Object locator, TreeRowKey rowKey);
-}
Deleted: trunk/richfaces/tree/src/main/java/org/richfaces/component/preserve/TreeNodeInfo.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/preserve/TreeNodeInfo.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/preserve/TreeNodeInfo.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -1,32 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.preserve;
-
-import org.richfaces.component.TreeRowKey;
-
-public interface TreeNodeInfo {
- public TreeRowKey getRowKey();
- public Object getData();
- public void setData(Object data);
- public boolean isLast();
- public boolean isLeaf();
-}
\ No newline at end of file
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/state/TreeState.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/state/TreeState.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/state/TreeState.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -27,18 +27,13 @@
import javax.faces.application.FacesMessage;
import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
import org.ajax4jsf.ajax.repeat.DataComponentState;
import org.ajax4jsf.ajax.repeat.DataVisitor;
import org.ajax4jsf.ajax.repeat.Range;
-import org.richfaces.component.CacheableTreeDataModel;
import org.richfaces.component.TreeRowKey;
import org.richfaces.component.UITree;
-import org.richfaces.component.preserve.TreeDataBatchLocator;
-import org.richfaces.component.preserve.TreeDataLocator;
import org.richfaces.component.state.events.TreeStateCommandsListener;
/**
@@ -48,14 +43,16 @@
public class TreeState implements DataComponentState, TreeStateCommandsListener, StateHolder {
private final class Visitor implements DataVisitor {
private TreeRowKey key;
+ private UITree tree;
- public Visitor(TreeRowKey key) {
+ public Visitor(TreeRowKey key, UITree tree) {
super();
this.key = key;
+ this.tree = tree;
}
public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
+ throws IOException {
tree.setRowKey(rowKey);
if (tree.isRowAvailable()) {
TreeRowKey nextKey = (TreeRowKey) rowKey;
@@ -90,6 +87,8 @@
return true;
}
};
+
+ private boolean stopInCollapsed = false;
private TreeRowKey selectedNode = null;
@@ -99,13 +98,9 @@
private Set queuedCollapsedNodes = new HashSet();
- private UITree tree;
-
-
- public TreeState(UITree tree, boolean stopInCollapsed) {
+ public TreeState(boolean stopInCollapsed) {
super();
this.stopInCollapsed = stopInCollapsed;
- this.tree = tree;
}
public boolean isExpanded(TreeRowKey rowKey) {
@@ -114,7 +109,7 @@
}
return expandedNodes.contains(rowKey)
- || queuedExpandedNodes.contains(rowKey);
+ || queuedExpandedNodes.contains(rowKey);
}
public boolean isSelected(TreeRowKey rowKey) {
@@ -149,8 +144,6 @@
private boolean _transient;
- private boolean stopInCollapsed;
-
private transient TreeRange treeRange = null;
public Range getRange() {
@@ -190,78 +183,16 @@
selectedNode = (TreeRowKey) _state[3];
queuedExpandedNodes = (Set) _state[4];
queuedCollapsedNodes = (Set) _state[5];
- treeDataModel = (CacheableTreeDataModel) UIComponentBase.restoreAttachedState(context, _state[6]);
- ValueBinding treeDataLocatorBinding = tree
- .getValueBinding(UITree.TREE_DATA_LOCATOR_BINDING);
- if (treeDataLocatorBinding != null) {
- Object object = treeDataLocatorBinding.getValue(context);
- if (object instanceof TreeDataLocator) {
- final TreeDataLocator treeDataLocator = (TreeDataLocator) object;
- if (treeDataModel != null) {
- try {
- treeDataModel.walk(context, new DataVisitor() {
-
- public void process(FacesContext arg0, Object arg1,
- Object arg2) throws IOException {
- treeDataModel.setRowKey(arg1);
- treeDataModel.setRowData(treeDataLocator
- .createData(treeDataModel.getRowData(),
- (TreeRowKey) arg1));
- }
-
- }, null, null);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- } else {
- TreeDataBatchLocator treeDataBatchLocator = (TreeDataBatchLocator) object;
- // TODO implement batch processing
- }
- }
}
public Object saveState(FacesContext context) {
- Object[] state = new Object[7];
+ Object[] state = new Object[6];
state[0] = expandedNodes;
state[1] = new Boolean(_transient);
state[2] = new Boolean(stopInCollapsed);
state[3] = selectedNode;
state[4] = queuedExpandedNodes;
state[5] = queuedCollapsedNodes;
- if (!UITree.PRESERVE_MODEL_REQUEST.equals(tree.getPreserveModel())) {
- ValueBinding treeDataLocatorBinding = tree
- .getValueBinding(UITree.TREE_DATA_LOCATOR_BINDING);
- if (treeDataLocatorBinding != null) {
- Object object = treeDataLocatorBinding.getValue(context);
- if (object instanceof TreeDataLocator) {
- final TreeDataLocator treeDataLocator = (TreeDataLocator) object;
- if (treeDataModel != null) {
- try {
- treeDataModel.walk(context, new DataVisitor() {
-
- public void process(FacesContext arg0,
- Object arg1, Object arg2)
- throws IOException {
- treeDataModel.setRowKey(arg1);
- treeDataModel.setRowData(treeDataLocator
- .createLocator(treeDataModel
- .getRowData(),
- (TreeRowKey) arg1));
- }
-
- }, null, null);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- } else {
- TreeDataBatchLocator treeDataBatchLocator = (TreeDataBatchLocator) object;
- // TODO implement batch processing
- }
- }
- state[6] = UIComponentBase.saveAttachedState(context, treeDataModel);
- }
return state;
}
@@ -277,21 +208,21 @@
this.stopInCollapsed = stopInCollapsed;
}
- private void visitNodes(TreeRange treeRange, TreeRowKey rootKey)
- throws IOException {
+ private void visitNodes(UITree tree, TreeRange treeRange, TreeRowKey rootKey)
+ throws IOException {
try {
this.treeRange = treeRange;
Object oldKey = tree.getRowKey();
tree.walkModel(FacesContext.getCurrentInstance(), new Visitor(
- rootKey), rootKey, null);
+ rootKey, tree), treeRange, rootKey, null);
tree.setRowKey(oldKey);
} finally {
this.treeRange = null;
}
}
- public void expandAll() throws IOException {
+ public void expandAll(UITree tree) throws IOException {
FacesContext context = FacesContext.getCurrentInstance();
queuedCollapsedNodes.clear();
// SubTreeChildrenAppender infoAppender = null;
@@ -301,17 +232,17 @@
// infoAppender = storedPersister.getAppender(null);
// }
- visitNodes(RANGE_UNCONSTRAINED, null);
+ visitNodes(tree, RANGE_UNCONSTRAINED, null);
}
- public void collapseAll() throws IOException {
+ public void collapseAll(UITree tree) throws IOException {
expandedNodes.clear();
queuedExpandedNodes.clear();
// RequestUtils.setStoredPersister(tree.getBaseClientId(context),
// context, null);
}
- public void collapseNode(TreeRowKey rowKey) throws IOException {
+ public void collapseNode(UITree tree, TreeRowKey rowKey) throws IOException {
expandedNodes.remove(rowKey);
queuedExpandedNodes.remove(rowKey);
queuedCollapsedNodes.add(rowKey);
@@ -323,7 +254,7 @@
// }
}
- public void expandNode(final TreeRowKey rowKey) throws IOException {
+ public void expandNode(UITree tree, final TreeRowKey rowKey) throws IOException {
FacesContext context = FacesContext.getCurrentInstance();
// SubTreeChildrenAppender infoAppender;
// if (storedPersister != null) {
@@ -333,40 +264,22 @@
// }
TreeRange range;
- if (treeDataModel == null) {
- // it's enough to traverse only subkeys of the node
- // we're opening
- range = new TreeRange() {
- public boolean processChildren(TreeRowKey nextKey) {
- return true;
- }
+ // it's enough to traverse only subkeys of the node
+ // we're opening
+ range = new TreeRange() {
+ public boolean processChildren(TreeRowKey nextKey) {
+ return true;
+ }
- public boolean processNode(TreeRowKey nextKey) {
- return (rowKey == null && nextKey == null)
- || nextKey.equals(rowKey)
- || nextKey.isSubKey(rowKey);
- }
+ public boolean processNode(TreeRowKey nextKey) {
+ return (rowKey == null && nextKey == null)
+ || nextKey.equals(rowKey)
+ || nextKey.isSubKey(rowKey);
+ }
- };
- visitNodes(range, rowKey);
- } else {
- final TreeRange expandedRange = (TreeRange) getRange();
- range = new TreeRange() {
+ };
+ visitNodes(tree, range, rowKey);
- public boolean processChildren(TreeRowKey key) {
- return expandedRange.processChildren(key) || key == null
- || key.isSubKey(rowKey);
- }
-
- public boolean processNode(TreeRowKey key) {
- return expandedRange.processNode(key) || key == null
- || key.isSubKey(rowKey) || key.equals(rowKey);
- }
-
- };
- visitNodes(range, rowKey);
- }
-
}
public void transferQueuedNodes() {
@@ -375,14 +288,4 @@
expandedNodes.removeAll(queuedCollapsedNodes);
queuedCollapsedNodes.clear();
}
-
- private CacheableTreeDataModel treeDataModel;
-
- public CacheableTreeDataModel getTreeDataModel() {
- return treeDataModel;
- }
-
- public void setTreeDataModel(CacheableTreeDataModel treeDataModel) {
- this.treeDataModel = treeDataModel;
- }
}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/CollapseAllCommandEvent.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/CollapseAllCommandEvent.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/CollapseAllCommandEvent.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -25,7 +25,9 @@
import javax.faces.component.UIComponent;
+import org.richfaces.component.UITree;
+
/**
* @author Nick - mailto:nbelaevski@exadel.com
* created 01.12.2006
@@ -43,7 +45,7 @@
private static final long serialVersionUID = 4670035007769731387L;
protected void execute(TreeStateCommandsListener commandsListener) throws IOException {
- commandsListener.collapseAll();
+ commandsListener.collapseAll((UITree) getComponent());
}
}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/CollapseNodeCommandEvent.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/CollapseNodeCommandEvent.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/CollapseNodeCommandEvent.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -26,6 +26,7 @@
import javax.faces.component.UIComponent;
import org.richfaces.component.TreeRowKey;
+import org.richfaces.component.UITree;
/**
* @author Nick - mailto:nbelaevski@exadel.com
@@ -44,7 +45,7 @@
}
protected void execute(TreeStateCommandsListener commandsListener) throws IOException {
- commandsListener.collapseNode(getRowKey());
+ commandsListener.collapseNode((UITree) getComponent(), getRowKey());
}
}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/ExpandAllCommandEvent.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/ExpandAllCommandEvent.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/ExpandAllCommandEvent.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -25,7 +25,9 @@
import javax.faces.component.UIComponent;
+import org.richfaces.component.UITree;
+
/**
* @author Nick - mailto:nbelaevski@exadel.com
* created 01.12.2006
@@ -43,7 +45,7 @@
private static final long serialVersionUID = -6665782819629856720L;
protected void execute(TreeStateCommandsListener commandsListener) throws IOException {
- commandsListener.expandAll();
+ commandsListener.expandAll((UITree) getComponent());
}
}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/ExpandNodeCommandEvent.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/ExpandNodeCommandEvent.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/ExpandNodeCommandEvent.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -26,6 +26,7 @@
import javax.faces.component.UIComponent;
import org.richfaces.component.TreeRowKey;
+import org.richfaces.component.UITree;
/**
* @author Nick - mailto:nbelaevski@exadel.com
@@ -44,7 +45,7 @@
}
protected void execute(TreeStateCommandsListener commandsListener) throws IOException {
- commandsListener.expandNode(getRowKey());
+ commandsListener.expandNode((UITree) getComponent(), getRowKey());
}
}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/TreeStateCommandsListener.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/TreeStateCommandsListener.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/state/events/TreeStateCommandsListener.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -26,6 +26,7 @@
import javax.faces.event.FacesListener;
import org.richfaces.component.TreeRowKey;
+import org.richfaces.component.UITree;
/**
* @author Nick - mailto:nbelaevski@exadel.com
@@ -33,8 +34,8 @@
*
*/
public interface TreeStateCommandsListener extends FacesListener {
- public void expandNode(TreeRowKey rowKey) throws IOException;
- public void collapseNode(TreeRowKey rowKey) throws IOException;
- public void expandAll() throws IOException;
- public void collapseAll() throws IOException;
+ public void expandNode(UITree tree, TreeRowKey rowKey) throws IOException;
+ public void collapseNode(UITree tree, TreeRowKey rowKey) throws IOException;
+ public void expandAll(UITree tree) throws IOException;
+ public void collapseAll(UITree tree) throws IOException;
}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeDataModelEventNavigator.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeDataModelEventNavigator.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeDataModelEventNavigator.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -112,10 +112,6 @@
public abstract void afterUp(int levels) throws IOException;
public abstract void afterDown() throws IOException;
- protected UITree getTree() {
- return tree;
- }
-
public void setLastElement() {
lastElement = true;
}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -48,11 +48,98 @@
import org.richfaces.component.UITree;
import org.richfaces.component.UITreeNode;
import org.richfaces.component.nsutils.NSUtils;
+import org.richfaces.component.state.TreeRange;
import org.richfaces.component.state.TreeState;
import org.richfaces.component.state.TreeStateAdvisor;
public abstract class TreeRendererBase extends CompositeRenderer {
+ private final class RendererDataModelEventNavigator extends
+ TreeDataModelEventNavigator {
+ private final FacesContext context;
+ private final UITree tree;
+ private final Flag droppedDownToLevelFlag;
+ private final ResponseWriter writer;
+
+ private String clientId;
+ private boolean expanded;
+ private boolean showLines;
+
+ private RendererDataModelEventNavigator(UITree tree,
+ TreeRowKey floatingKey, FacesContext context, Flag droppedDownToLevelFlag) {
+ super(tree, floatingKey);
+ this.context = context;
+ this.tree = tree;
+ this.droppedDownToLevelFlag = droppedDownToLevelFlag;
+ this.writer = context.getResponseWriter();
+
+ this.expanded = this.tree.isExpanded();
+ this.showLines = this.tree.isShowConnectingLines();
+ this.clientId = getClientId();
+ }
+
+ public void followRowKey(TreeRowKey newRowKey) throws IOException {
+ super.followRowKey(newRowKey);
+
+ this.expanded = this.tree.isExpanded();
+ this.clientId = getClientId();
+ }
+
+ private String getClientId() {
+ Object rowKey = tree.getRowKey();
+ String id;
+ if (rowKey == null) {
+ id = tree.getClientId(context)
+ + NamingContainer.SEPARATOR_CHAR;
+ } else {
+ id = tree.getNodeFacet().getClientId(context)
+ + NamingContainer.SEPARATOR_CHAR;
+ }
+ return id;
+ }
+
+ public void afterDown() throws IOException {
+ openLevelDownTable(context, tree, writer);
+ }
+
+ public void afterUp(int levels) throws IOException {
+ for (int i = 0; i < levels; i++) {
+ closeLevelDownTable(context, tree, writer);
+ writer.endElement("td");
+ writer.endElement("tr");
+ }
+ }
+
+ public void beforeDown() throws IOException {
+ droppedDownToLevelFlag.setFlag();
+
+ writer.startElement("tr", tree);
+ getUtils().writeAttribute(writer, "id", clientId + "childs");
+
+ if (!expanded) {
+ getUtils().writeAttribute(writer, "style", "display: none;");
+ }
+
+ if (this.getRowKey() != null) {
+ writer.startElement("td", tree);
+ if (!isStackedLastElement()) {
+ if (showLines)
+ getUtils().writeAttribute(writer, "class",
+ "dr-tree-h-ic-line");
+ }
+ writer.endElement("td");
+ }
+
+ writer.startElement("td", tree);
+ getUtils().writeAttribute(writer, "colspan", "2");
+ getUtils().writeAttribute(writer, "id", clientId + "childs:td");
+ getUtils().writeAttribute(writer, "valign", "top");
+ }
+
+ public void beforeUp(int levels) {
+ }
+ }
+
private class DataVisitorWithLastElement implements DataVisitor,
LastElementAware {
@@ -154,12 +241,12 @@
if (null != adviseOpened) {
if (adviseOpened.booleanValue()) {
if (!componentState.isExpanded(rowKey)) {
- componentState.expandNode(rowKey);
+ componentState.expandNode(tree, rowKey);
}
}
else {
if (componentState.isExpanded(rowKey)) {
- componentState.collapseNode(rowKey);
+ componentState.collapseNode(tree, rowKey);
}
}
}
@@ -362,64 +449,6 @@
TreeRowKey rowKey = (TreeRowKey) key;
- final TreeDataModelEventNavigator levelNavigator = new TreeDataModelEventNavigator(
- input, rowKey) {
-
- public void afterDown() throws IOException {
- openLevelDownTable(context, input, writer);
- }
-
- public void afterUp(int levels) throws IOException {
- for (int i = 0; i < levels; i++) {
- closeLevelDownTable(context, input, writer);
- writer.endElement("td");
- writer.endElement("tr");
- }
- }
-
- public void beforeDown() throws IOException {
- droppedDownToLevelFlag.setFlag();
-
- String id;
-
- Object rowKey = getTree().getRowKey();
- if (rowKey == null) {
- id = getTree().getClientId(context)
- + NamingContainer.SEPARATOR_CHAR;
- } else {
- id = getTree().getNodeFacet().getClientId(context)
- + NamingContainer.SEPARATOR_CHAR;
- }
-
-
- writer.startElement("tr", input);
- getUtils().writeAttribute(writer, "id", id + "childs");
-
- if (!getTree().isExpanded()) {
- getUtils()
- .writeAttribute(writer, "style", "display: none;");
- }
-
- if (this.getRowKey() != null) {
- writer.startElement("td", input);
- if (!isStackedLastElement()) {
- if (getTree().isShowConnectingLines())
- getUtils().writeAttribute(writer, "class",
- "dr-tree-h-ic-line");
- }
- writer.endElement("td");
- }
-
- writer.startElement("td", input);
- getUtils().writeAttribute(writer, "colspan", "2");
- getUtils().writeAttribute(writer, "id", id + "childs:td");
- getUtils().writeAttribute(writer, "valign", "top");
- }
-
- public void beforeUp(int levels) {
- }
- };
-
final StringHolder selectionValueHolder = new StringHolder();
//Object savedRowKey = input.getRowKey();
@@ -434,9 +463,37 @@
input.setRowKey(null);
}
+ TreeDataModelEventNavigator levelNavigator = new RendererDataModelEventNavigator(input, rowKey, context,
+ droppedDownToLevelFlag);
+
+ final TreeRange stateRange = (TreeRange) input.getComponentState().getRange();
+ TreeRange treeRange = new TreeRange() {
+
+ public boolean processChildren(TreeRowKey rowKey) {
+ return stateRange.processChildren(rowKey);
+ }
+
+ public boolean processNode(TreeRowKey rowKey) {
+ Object currentKey = input.getRowKey();
+
+ if (currentKey == null ? rowKey != null : !currentKey.equals(rowKey)) {
+ //currentKey NE rowKey
+ input.setRowKey(rowKey);
+ }
+
+ UITreeNode nodeFacet = input.getNodeFacet();
+ if (!nodeFacet.isRendered()) {
+ return false;
+ }
+
+ return stateRange.processNode(rowKey);
+ }
+
+ };
+
input.walk(context, new DataVisitorWithLastElement(writer,
selectionValueHolder, droppedDownToLevelFlag, input,
- levelNavigator), key, null);
+ levelNavigator), treeRange, key, null);
if (key != null) {
closeLevelDownTable(context, input, writer);
Modified: trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/MockTreeStateCommandsListener.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/MockTreeStateCommandsListener.java 2007-06-26 16:13:22 UTC (rev 1326)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/state/events/MockTreeStateCommandsListener.java 2007-06-26 16:14:55 UTC (rev 1327)
@@ -24,6 +24,7 @@
import java.io.IOException;
import org.richfaces.component.TreeRowKey;
+import org.richfaces.component.UITree;
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
@@ -37,19 +38,19 @@
private TreeRowKey collapseNode;
private TreeRowKey expandNode;
- public void collapseAll() throws IOException {
+ public void collapseAll(UITree tree) throws IOException {
this.collapseAll = true;
}
- public void collapseNode(TreeRowKey rowKey) throws IOException {
+ public void collapseNode(UITree tree, TreeRowKey rowKey) throws IOException {
this.collapseNode = rowKey;
}
- public void expandAll() throws IOException {
+ public void expandAll(UITree tree) throws IOException {
this.expandAll = true;
}
- public void expandNode(TreeRowKey rowKey) throws IOException {
+ public void expandNode(UITree tree, TreeRowKey rowKey) throws IOException {
this.expandNode = rowKey;
}
@@ -73,19 +74,19 @@
class MockExceptionTreeStateCommandsListener extends MockTreeStateCommandsListener {
- public void collapseAll() throws IOException {
+ public void collapseAll(UITree tree) throws IOException {
throw new IOException();
}
- public void collapseNode(TreeRowKey rowKey) throws IOException {
+ public void collapseNode(UITree tree, TreeRowKey rowKey) throws IOException {
throw new IOException();
}
- public void expandAll() throws IOException {
+ public void expandAll(UITree tree) throws IOException {
throw new IOException();
}
- public void expandNode(TreeRowKey rowKey) throws IOException {
+ public void expandNode(UITree tree, TreeRowKey rowKey) throws IOException {
throw new IOException();
}
17 years, 6 months
JBoss Rich Faces SVN: r1326 - in trunk/sandbox/scrollable-grid/src/main: javascript/ClientUI/controls/grid and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2007-06-26 12:13:22 -0400 (Tue, 26 Jun 2007)
New Revision: 1326
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js
trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
Log:
add column hide JS API, server part
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-06-26 15:55:43 UTC (rev 1325)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-06-26 16:13:22 UTC (rev 1326)
@@ -5,6 +5,7 @@
import java.io.Serializable;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -32,6 +33,8 @@
private boolean fake;
+ private HashSet ids = new HashSet();
+
private Object rowClasses[];
private int rowClassesSize;
@@ -417,5 +420,13 @@
this.rowClasses = rowClasses.toArray();
rowClassesSize = this.rowClasses.length;
}
+ }
+
+ public HashSet getIds() {
+ return ids;
+ }
+
+ public void addId(String id) {
+ ids.add(id);
}
}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-06-26 15:55:43 UTC (rev 1325)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-06-26 16:13:22 UTC (rev 1326)
@@ -98,7 +98,7 @@
int cell_index = state.getCellIndex();
String client_id = state.getClientId();
-
+ state.addId(column.getId());
headerCellTemplate = getHeaderCellTemplate();
ComponentVariables variables = ComponentsVariableResolver.getVariables(headerCellTemplate, column);
@@ -334,7 +334,7 @@
options.addOption("columnsCount", new Integer(columnCount));
options.addOption("rowsCount", new Integer(grid.getRows()));
options.addEventHandler("onselectionchange");
-
+ options.addOption("ids", GridRendererState.getRendererState(context).getIds());
JSFunction function = new JSFunction("new ClientUI.controls.grid.ScrollableGrid");
function.addParameter(options);
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js 2007-06-26 15:55:43 UTC (rev 1325)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js 2007-06-26 16:13:22 UTC (rev 1326)
@@ -129,8 +129,10 @@
var i = 0, h, j=0;
var cols = $A(this.headerFrozenRow.getElement().getElementsByTagName("col"));
var cells = $A(this.headerFrozenRow.getElement().rows[0].cells);
+ var ids = this.grid.options.ids;
cells.each(function(cell) {
columns[i] = {
+ columnId: ids[i],
col: $(cols[j]),
width: parseInt(cols[j].width), //Element.getWidth(cell),
innerHTML: cell.innerHTML,
@@ -163,9 +165,10 @@
j=0;
cols = $A(this.headerRow.getElement().getElementsByTagName("col"));
- cells = $A(this.headerRow.getElement().rows[0].cells);
+ cells = $A(this.headerRow.getElement().rows[0].cells);
cells.each(function(cell) {
columns[i] = {
+ columnId: ids[i],
col: $(cols[j]),
width: parseInt(cols[j].width), //Element.getWidth(cell),
innerHTML: cell.innerHTML,
@@ -429,10 +432,12 @@
},
hideColumn: function(index, frozen) {
- var colomn = this._columns.splice(index,1)[0];
- colomn.col.parentNode.removeChild(colomn.col);
- colomn.bodyCol.parentNode.removeChild(colomn.bodyCol);
- colomn.footerCol.parentNode.removeChild(colomn.footerCol);
+ var column = this._columns.splice(index,1)[0];
+ var input = $(this.grid.getElement().id + "_hc")
+ input.value = input.value + column.columnId + ",";
+ column.col.parentNode.removeChild(column.col);
+ column.bodyCol.parentNode.removeChild(column.bodyCol);
+ column.footerCol.parentNode.removeChild(column.footerCol);
var rows;
if(frozen) {
rows = this.headerFrozenRow.getElement().rows;
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js 2007-06-26 15:55:43 UTC (rev 1325)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/ScrollableGrid.js 2007-06-26 16:13:22 UTC (rev 1326)
@@ -121,15 +121,15 @@
doCollapse: function(index) {
var header = this.getHeader();
- var length = header.headerFrozenRow.getElement().rows[0].cells.length;
- if(index < length) {
- this.hideColumn(index, true);
- } else {
- index -= fcount;
- length = header.headerRow.getElement().rows[0].cells.length;
- if (index < length - 1){
- this.hideColumn(index, false);
+ var flength = header.headerFrozenRow.getElement().rows[0].cells.length;
+ var nlength = header.headerRow.getElement().rows[0].cells.length;
+ if(index < flength + nlength - 1) {
+ var frozen = true;
+ if(index >= flength) {
+ index -= fcount;
+ frozen = false;
}
+ this.hideColumn(index, frozen);
}
},
Modified: trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-06-26 15:55:43 UTC (rev 1325)
+++ trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid.jspx 2007-06-26 16:13:22 UTC (rev 1326)
@@ -162,6 +162,7 @@
</div>
</div>
+ <input type="hidden" name="#{clientId}_hc" id="#{clientId}_hc"/>
<input type="hidden" name="#{clientId}_state_input" id="#{clientId}_state_input"/>
<input type="hidden" name="#{clientId}_options_input" id="#{clientId}_options_input"/>
<input type="hidden" name="#{clienId}_rows_input" id="#{clientId}_rows_input" value="#{rows_count}"/>
@@ -170,9 +171,7 @@
<f:call name="contributorsEncodeHere"/>
</div>
-
- <f:call name="tearDownState"/>
-
+
<jsp:scriptlet>
if(component.getFacets().containsKey("splash")){
UIComponent splash = component.getFacet("splash");
@@ -193,6 +192,7 @@
// ]]>
</script>
+ <f:call name="tearDownState"/>
</f:root>
17 years, 6 months
JBoss Rich Faces SVN: r1325 - trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-26 11:55:43 -0400 (Tue, 26 Jun 2007)
New Revision: 1325
Added:
trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html/ScrollableGridRendererTest.java
Log:
test for renderer
Added: trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html/ScrollableGridRendererTest.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html/ScrollableGridRendererTest.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/test/java/org/richfaces/renderkit/html/ScrollableGridRendererTest.java 2007-06-26 15:55:43 UTC (rev 1325)
@@ -0,0 +1,144 @@
+package org.richfaces.renderkit.html;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.UIOutput;
+import javax.faces.component.html.HtmlOutputText;
+
+import org.ajax4jsf.ajax.repeat.ExtendedDataModel;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UIScrollableGridColumn;
+import org.richfaces.component.html.HtmlScrollableGrid;
+import org.richfaces.component.html.HtmlScrollableGridColumn;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class ScrollableGridRendererTest extends AbstractAjax4JsfTestCase{
+
+ HtmlScrollableGrid grid;
+ int columns = 7;
+
+ public ScrollableGridRendererTest(String arg0) {
+ super(arg0);
+ }
+
+ public void setUp() throws Exception {
+
+ super.setUp();
+
+ // create grid
+ grid = (HtmlScrollableGrid)application.createComponent("org.richfaces.component.ScrollableGrid");
+ grid.setId("grid");
+ grid.setFrozenColCount(3);
+
+ // add columns
+ for (int i = 0; i < columns; i++) {
+
+ UIScrollableGridColumn column = (UIScrollableGridColumn) createComponent(
+ HtmlScrollableGridColumn.COMPONENT_TYPE,
+ HtmlScrollableGridColumn.class.getName(),
+ null, null, null);
+ UIOutput outputText = (UIOutput) createComponent(
+ HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(),
+ null, null, null);
+
+ column.getFacets().put("header", outputText);
+ column.getFacets().put("footer", outputText);
+ column.getChildren().add(outputText);
+
+ grid.getChildren().add(column);
+ grid.setFirst(0);
+ grid.setRows(40);
+ }
+
+ facesContext.getViewRoot().getChildren().add(grid);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ grid = null;
+ }
+
+
+ public void testRenderingFrozenNormalColumns()throws Exception{
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ HtmlElement div = page.getHtmlElementById(grid.getClientId(facesContext));
+ assertNotNull(div);
+ assertEquals("div", div.getNodeName());
+
+ String classAttr = div.getAttributeValue("class");
+ assertTrue(classAttr.contains("ClientUI_Grid"));
+
+ Iterator childIter= div.getChildElementsIterator();
+
+ for (; childIter.hasNext();) {
+
+ HtmlElement elem = (HtmlElement) childIter.next();
+ assertNotNull(elem);
+
+ boolean res = (elem.getNodeName().equals("div") || elem.getNodeName().equals("input"));
+ assertEquals(true, res);
+
+ if(elem.getNodeName().equals("div")){
+
+ String elemClassAttr = elem.getAttributeValue("class");
+ assertTrue(elemClassAttr.contains("ClientUI_InlineBox"));
+ boolean templates = elem.getId().equals(grid.getId()+ "_GridBodyTemplate") || elem.getId().equals(grid.getId()+ "_GridFooterTemplate") || elem.getId().equals(grid.getId()+ "_GridHeaderTemplate");
+ assertTrue(templates);
+ Iterator divIter = elem.getChildElementsIterator();
+ HtmlElement inDiv = (HtmlElement) divIter.next();
+ assertNotNull(inDiv);
+ assertEquals("div", inDiv.getNodeName());
+
+ Iterator spanIter = inDiv.getChildElementsIterator();
+
+ for (;spanIter.hasNext();) {
+
+ HtmlElement span = (HtmlElement) spanIter.next();
+ assertNotNull(span);
+ assertEquals("span", span.getNodeName());
+ elemClassAttr = span.getAttributeValue("class");
+ assertNotNull(elemClassAttr);
+
+ if(span.getId().contains("FrozenBox")){
+ assertTrue(elemClassAttr.contains("ClientUI_TmplBox ClientUI_FrozenBox"));
+ }else if(span.getId().contains("NormalBox")){
+ assertTrue(elemClassAttr.contains("ClientUI_TmplBox ClientUI_NormalBox"));
+ }
+
+ String id = grid.getId();
+ for (int i = 0; i < columns; i++) {
+
+ HtmlElement hcell = page.getHtmlElementById(id + ":hc_" + i);
+ assertNotNull(hcell);
+ elemClassAttr = hcell.getAttributeValue("class");
+ assertTrue(elemClassAttr.contains("ClientUI_Grid_HC Idg-header-cell"));
+
+ for (int j = 0; j < grid.getRows(); j++) {
+ HtmlElement bcell = page.getHtmlElementById(id + ":c_" + j + "_" + i);
+ assertNotNull(bcell);
+ elemClassAttr = bcell.getAttributeValue("class");
+ assertTrue(elemClassAttr.contains("ClientUI_Grid_BC Idg-column-cell"));
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
+}
17 years, 6 months
JBoss Rich Faces SVN: r1324 - in trunk/richfaces/tree/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-06-26 11:20:23 -0400 (Tue, 26 Jun 2007)
New Revision: 1324
Modified:
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
trunk/richfaces/tree/src/main/templates/htmlTreeNode.jspx
Log:
Compact JS events code for toggle actions.
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java 2007-06-26 14:06:46 UTC (rev 1323)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java 2007-06-26 15:20:23 UTC (rev 1324)
@@ -115,7 +115,7 @@
result.append("', ");
result.append("form.id, ");
result.append("'', ");
- result.append("params);}; return false;");
+ result.append("params);};");
return result.toString();
}
Modified: trunk/richfaces/tree/src/main/templates/htmlTreeNode.jspx
===================================================================
--- trunk/richfaces/tree/src/main/templates/htmlTreeNode.jspx 2007-06-26 14:06:46 UTC (rev 1323)
+++ trunk/richfaces/tree/src/main/templates/htmlTreeNode.jspx 2007-06-26 15:20:23 UTC (rev 1324)
@@ -64,7 +64,7 @@
]]>
</jsp:scriptlet>
<a href="#" id="#{clientId}:handle"
- onclick="#{this:getToggleScript(context, component, 'handle')}">
+ onclick="#{this:getToggleScript(context, component, 'handle')} return false;">
<jsp:scriptlet>
<![CDATA[
17 years, 6 months
JBoss Rich Faces SVN: r1323 - trunk/docs/userguide/en/src/main/docbook/modules.
by richfaces-svn-commits@lists.jboss.org
Author: vkorluzhenko
Date: 2007-06-26 10:06:46 -0400 (Tue, 26 Jun 2007)
New Revision: 1323
Modified:
trunk/docs/userguide/en/src/main/docbook/modules/RFCfaq.xml
Log:
added new questions, fixed spelling errors
Modified: trunk/docs/userguide/en/src/main/docbook/modules/RFCfaq.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/modules/RFCfaq.xml 2007-06-26 14:03:43 UTC (rev 1322)
+++ trunk/docs/userguide/en/src/main/docbook/modules/RFCfaq.xml 2007-06-26 14:06:46 UTC (rev 1323)
@@ -161,9 +161,9 @@
<section>
<?dbhtml filename="HowtousesuggestionBox"?>
- <title>How to use <rich:suggestionBox> inside the
- <rich:modalPanel> content? When I use it the popup suggestion
- list doesn't show since it is behind the modalPanel.</title>
+ <title>How to use suggestionBox inside the modalPanel content? When I use it the
+ popup suggestion list doesn't show since it is behind the
+ modalPanel.</title>
<para>First of all to solve this problem you should use the latest versions of
Ajax4JSF 1.1.2-SNAPSHOT and Richfaces 3.0.2-SNAPSHOT.</para>
<para> Nightly builds are available <ulink
@@ -219,7 +219,7 @@
<?dbhtml filename="Isitpossibletocreatedynamicmenu"?>
<title>Is it possible to create dynamic menu using <rich:dropDownMenu>
component?</title>
- <para><emphasis role="bold"><rich:dropDown></emphasis> menu is a
+ <para><emphasis role="bold"><rich:dropDownMenu></emphasis> is a
standard JSF component. So, creation the menu dynamically from the Java
Script code is the same as for any other jsf component.</para>
</section>
@@ -237,8 +237,7 @@
<section>
<?dbhtml filename="HowtocustomizesimpleTogglePanel"?>
- <title>How to customize <rich:simpleTogglePanel>? I need to change
- icon for toggler.</title>
+ <title>How to customize simpleTogglePanel? I need to change icon for toggler.</title>
<para>To customize icon for toggler use "openMarker" and
"closeMarker" facets.</para>
</section>
@@ -262,7 +261,8 @@
...
]]></programlisting>
<para>Also online demo of using <emphasis role="bold"
- ><rich:dropDownMenu></emphasis> is available <ulink
+ ><rich:dropDownMenu></emphasis> component is available
+ <ulink
url="http://livedemo.exadel.com/richfaces-demo/richfaces/dropDownMenu.jsf"
>here</ulink>.</para>
</section>
@@ -307,4 +307,74 @@
placed anywhere in the layout.</para>
</section>
+ <section>
+ <?dbhtml filename="HowtogetaacommandButton"?>
+ <title>How to get a commandButton working within the modalPanel?</title>
+ <para>Simple code is placed below:</para>
+ <programlisting role="XML"><![CDATA[...
+ <rich:modalPanel>
+ <f:facet name="header">
+ <h:outputText value="Test" />
+ </f:facet>
+ <f:facet name="controls">
+ <h:commandLink value="Close" style="cursor:pointer" onclick="Richfaces.hideModalPanel('mp')" />
+ </f:facet>
+ <h:form>
+ <t:commandButton value="Test" action="#{TESTCONTROLLER.test}" />
+ </h:form>
+ </rich:modalPanel>
+...
+]]></programlisting>
+ </section>
+
+ <section>
+ <?dbhtml filename="Howtoremembercurrentselectedtab"?>
+ <title>How to remember current selected tab?</title>
+ <para>To implement this feature use the "action" attribute of
+ <emphasis role="bold"><rich:tab></emphasis> and
+ "selectedTab" of the <emphasis role="bold"
+ ><rich:tabPanel></emphasis>. Simple code is placed below:</para>
+ <programlisting role="XML"><![CDATA[...
+ <rich:tab label="MyName" id="MyName" action="#{MySessionBean.activateSecuritySettingsTab}" >
+ ...
+ <rich:tabPanel id="tblPnl" selectedTab="#{MySessionBean.activeTabName}">
+ ...
+ </rich:tabPanel>
+ </rich:tab>
+...
+]]></programlisting>
+ </section>
+
+ <section>
+ <?dbhtml filename="Howtoretrievethecurrentvalue"?>
+ <title>How to retrieve the current value from the inputNumberSlider?</title>
+ <para>To catch the value of the inputNumberSlider from the JavaScript you can use
+ the following approach:</para>
+ <programlisting role="XML"><![CDATA[...
+ <rich:inputNumberSlider width="500" step="20"
+ onchange="someFunctionCall(this.input.value)"
+ minValue="0"
+ maxValue="500"
+ value="0"
+ showInput="false"
+ showToolTip="false"
+ showBoundaryValues="false"/>
+ ...
+ <script>
+ function someFunctionCall(value) {
+ alert(value);
+ }
+ </script>
+...
+]]></programlisting>
+ </section>
+
+ <section>
+ <?dbhtml filename="Howtoretrievethecurrentvalue"?>
+ <title>How to apply skins to the standard input components?</title>
+ <para>The answer could be found <ulink
+ url="http://www.jboss.com/index.html?module=bb&op=viewtopic&t=103494"
+ >here</ulink>.</para>
+ </section>
+
</chapter>
17 years, 6 months
JBoss Rich Faces SVN: r1322 - trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/json.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2007-06-26 10:03:43 -0400 (Tue, 26 Jun 2007)
New Revision: 1322
Modified:
trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js
Log:
code improvement and optimisation
Modified: trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js
===================================================================
--- trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js 2007-06-26 13:14:01 UTC (rev 1321)
+++ trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js 2007-06-26 14:03:43 UTC (rev 1322)
@@ -8,230 +8,116 @@
//
// Modified by Alexander J. Smirnov to use as JSF AJAX-like components.
- JSDocument = function(js) {
-// AJAX_Log( " Response document "+Dump(js,1));
-// AJAX_Log( " Response document buildCache: "+typeof(js.buildCache));
- this.idsCache = {};
- js.buildCache(this.idsCache);
- this.documentElement = js;//this._parseJS(js);
- }
-
-// DOM document like class for parsing javaScript response.
- JSDocument.prototype = {
-// idsCache: {},
-
-
-// documentElement : null,
-
-
- getElementById: function( elementId ){
- return this.idsCache[elementId];
- },
-
- getElementsByTagName: function( tagname ){
- return [];
- },
- createElement: function(js){
- return new E(js.tag);
- },
-
-
- createTextNode: function(text){
- return new T(text);
- },
-
- createComment: function(text){
- return new C(text);
- },
-
- createCDATASection: function(text){
- return new D(text);
- }
-
-
- }
-
// DOM - like elements for JSRequest. JS serialiser encode
// XML sax events to creation of corresponding objects.
- JSNode = function(){
-// this.tag = null;
-// this.attrs = {};
-// this.childs = [];
-// this.value = "";
- };
-
- JSNode.prototype = {
- tag : null,
- attrs : {},
- childs : [],
- parentNode : null,
- value : "",
- _symbols : {
- '&':"&",
- '<':"<",
- '>':">",
- '"':""",
- '\'':"'",
- '\u00A0':" "
- },
- // Public functions
- getAttribute : function(aname) {
- return this.attrs[aname];
- },
- setAttribute : function(aname,avalue){
- this.attrs[aname]=avalue;
- },
- getInnerHTML : function(context){
- var html = "";
- for( var i = 0; i < this.childs.length; i++ ){
- html += this.childs[i].getOuterHTML(context);
- }
- return html;
- },
-// getOuterHTML : function(){return ""},
-
- appendChild : function(child){
- this.childs[this.childs.length]=child;
- child.parentNode = this;
- },
-
- buildCache : function(cache){
- if(this.attrs.id){
- cache[this.attrs.id]=this;
- }
- for( var i in this.childs ){
- this.childs[i].buildCache(cache);
- this.childs[i].parentNode = this;
- }
- },
-
- // TODO - make real clone ...
- cloneNode : function(withChildren){
- },
+JSNode = function() {
+};
+// Base node
+JSNode.prototype = {
+ tag : null,
+ attrs : {},
+ childs : [],
+ value : "",
+ _symbols : {
+ '&':"&",
+ '<':"<",
+ '>':">",
+ '"':""",
+ '\'':"'",
+ '\u00A0':" "
+ },
+ // Public functions
+ getInnerHTML : function(context) {
+ var html = "";
+ for (var i = 0; i < this.childs.length; i++)
+ html += this.childs[i].getContent(context);
+ return html;
+ },
// Escape XML symbols - < > & ' ...
- xmlescape : function(text){
- var t = text;
- if (t) {
- //handle non-strings
- t = t.toString();
- } else {
- t = "";
- }
-
- for( var i in this._symbols ){
-// text = text.replace(i,this._symbols[i]);
- t = t.split(i).join(this._symbols[i])
- }
- return t;
- },
-
- // Escape JavaScript function
- JSEscape : function(text){
-// for( var i in this._symbols ){
-// text = text.replace(i,this._symbols[i]);
-// text = text.split(i).join(this._symbols[i])
-// }
- return text;
- }
- }
- // Element node
- E = function(tagname,attributes,childnodes){
-
- this.tag = tagname;
- this.attrs = attributes;
- if(childnodes){
- this.childs = childnodes;
- } else {
- this.childs = [];
- }
- };
+ xmlEscape : function(value) {
+ var text = value ? value.toString() : "";
+ for(var i in this._symbols )
+ text = text.replace(i,this._symbols[i]);
+ return text;
+ }
+};
- E.prototype = new JSNode();
- E.prototype.getOuterHTML = function(context){
- // AJAX_Log("Get Outer HTML for object:"+Dump(this);
- var html = "<"+this.tag;
- var inner = this.getInnerHTML(context);
- for( var i in this.attrs ){
- if (!this.attrs.hasOwnProperty(i)) {
- continue ;
- }
-
- var attrValue = this.attrs[i];
-
- if (typeof attrValue == "function") {
- attrValue = attrValue(context);
- }
-
- if (attrValue) {
- html += " "+(i=='className'?'class':i)+'="'+(i.substring(0,2)=="on"?this.JSEscape(attrValue):this.xmlescape(attrValue))+'"';
- // html+= " "+i+'="'+this.xmlescape(this.attrs[i])+'"';
- }
- }
- if(inner == ""){
- html+= " />";
- } else {
- html+= " >"+inner+"</"+this.tag+">";
- }
- return html;
- };
+// Element node
+E = function(tagname,attributes,childnodes) {
+ this.tag = tagname;
+ if (attributes) this.attrs = attributes;
+ if(childnodes) this.childs = childnodes;
+};
+E.prototype = new JSNode();
+E.prototype.getContent = function(context) {
+ var html = "<"+this.tag;
+ var inner = this.getInnerHTML(context);
+ for(var i in this.attrs) {
- // Escaped Text node
- ET = function(text) {
- this.value = text;
- }
+ var attrValue = this.attrs[i];
+
+ if (typeof attrValue == "function")
+ attrValue = attrValue(context);
+
+ if (attrValue)
+ html += " "+(i=='className'?'class':i)+'="'+this.xmlEscape(attrValue)+'"';
+ }
+ if(inner == "") html+= "/>";
+ else html+= ">"+inner+"</"+this.tag+">";
+ return html;
+};
- ET.prototype = new JSNode();
- ET.prototype.getOuterHTML = function(context){
- var value = this.value;
- if (typeof value == "function") {
- value = value(context);
- }
-
- if (value) {
- return value;
- }
+// Escaped Text node
+ET = function(text) {
+ this.value = text;
+};
+
+//ET.prototype = new JSNode();
+ET.prototype.getContent = function(context) {
+ var value = this.value;
+ if (typeof value == "function")
+ value = value(context);
+
+ if (value) return value;
- return "";
- }
+ return "";
+};
- // Text node
- T = function(text) {
- this.value = text;
- }
+// Text node
+T = function(text) {
+ this.value = text;
+};
- T.prototype = new JSNode();
- T.prototype.getOuterHTML = function(context){
- var value = this.value;
- if (typeof value == "function") {
- value = value(context);
- }
+T.prototype = new JSNode();
+T.prototype.getContent = function(context) {
+ var value = this.value;
+ if (typeof value == "function")
+ value = value(context);
- if (value) {
- return this.xmlescape(value);
- }
-
- return "";
- }
+ if (value) return this.xmlEscape(value);
- // Comment node
- C = function(text) {
- this.value = text;
- }
+ return "";
+};
- C.prototype = new JSNode();
- C.prototype.getOuterHTML = function(context){
- return "<!--"+this.value+"-->";
- }
+// Comment node
+C = function(text) {
+ this.value = text;
+};
+
+//C.prototype = new JSNode();
+C.prototype.getContent = function(context) {
+ return "<!--"+this.value+"-->";
+};
- // CDATA Section node.
- D = function(text) {
- this.value = text;
- }
+// CDATA Section node.
+D = function(text) {
+ this.value = text;
+};
- D.prototype = new JSNode();
- D.prototype.getOuterHTML = function(context){
- return "<![CDATA["+this.value+"]]>";
- }
+//D.prototype = new JSNode();
+D.prototype.getContent = function(context) {
+ return "<![CDATA["+this.value+"]]>";
+};
17 years, 6 months
JBoss Rich Faces SVN: r1321 - in trunk/richfaces/tree/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-06-26 09:14:01 -0400 (Tue, 26 Jun 2007)
New Revision: 1321
Modified:
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
trunk/richfaces/tree/src/main/templates/htmlTreeNode.jspx
Log:
Compact JS events code for toggle actions.
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java 2007-06-26 11:13:23 UTC (rev 1320)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/NodeRendererBase.java 2007-06-26 13:14:01 UTC (rev 1321)
@@ -96,7 +96,7 @@
StringBuffer buffer = new StringBuffer();
function.appendScript(buffer);
- buffer.append(";");
+ buffer.append("; return false;");
return buffer.toString();
} else if (UITree.SWITCH_SERVER.equals(tree.getSwitchType())) {
String paramName = id + NODE_EXPANDED_INPUT_SUFFIX;
@@ -115,7 +115,7 @@
result.append("', ");
result.append("form.id, ");
result.append("'', ");
- result.append("params);};");
+ result.append("params);}; return false;");
return result.toString();
}
Modified: trunk/richfaces/tree/src/main/templates/htmlTreeNode.jspx
===================================================================
--- trunk/richfaces/tree/src/main/templates/htmlTreeNode.jspx 2007-06-26 11:13:23 UTC (rev 1320)
+++ trunk/richfaces/tree/src/main/templates/htmlTreeNode.jspx 2007-06-26 13:14:01 UTC (rev 1321)
@@ -31,7 +31,7 @@
<f:call name="initializeLines" />
<f:call name="initializeResources" />
- <tr id="#{clientId}:mainRow" onclick="#{component.attributes['onclick']}; #{this:getToggleScript(context, component, 'mainRow')} return false;" >
+ <tr id="#{clientId}:mainRow" onclick="#{component.attributes['onclick']} #{this:getToggleScript(context, component, 'mainRow')}" >
<f:call name="encodeAttributeParameters" />
<f:call name="utils.encodePassThruWithExclusions">
@@ -64,7 +64,7 @@
]]>
</jsp:scriptlet>
<a href="#" id="#{clientId}:handle"
- onclick="#{this:getToggleScript(context, component, 'handle')} return false;">
+ onclick="#{this:getToggleScript(context, component, 'handle')}">
<jsp:scriptlet>
<![CDATA[
17 years, 6 months
JBoss Rich Faces SVN: r1320 - trunk/docs/userguide/en/src/main/docbook/modules.
by richfaces-svn-commits@lists.jboss.org
Author: vkorluzhenko
Date: 2007-06-26 07:13:23 -0400 (Tue, 26 Jun 2007)
New Revision: 1320
Modified:
trunk/docs/userguide/en/src/main/docbook/modules/RFCfaq.xml
Log:
added questuions
Modified: trunk/docs/userguide/en/src/main/docbook/modules/RFCfaq.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/modules/RFCfaq.xml 2007-06-26 10:50:12 UTC (rev 1319)
+++ trunk/docs/userguide/en/src/main/docbook/modules/RFCfaq.xml 2007-06-26 11:13:23 UTC (rev 1320)
@@ -287,7 +287,7 @@
<section>
<?dbhtml filename="Howtoaddalinktothetreenode"?>
- <title>How to add a link to a tree node?</title>
+ <title>How to add a link to the tree node?</title>
<para>Simple code is placed below:</para>
<programlisting role="XML"><![CDATA[...
<rich:tree value="#{bean.data}" var="data">
@@ -299,4 +299,12 @@
]]></programlisting>
</section>
+ <section>
+ <?dbhtml filename="Isitpossibletoplacetabsvertically"?>
+ <title>Is it possible to place tabs upright in the tabPanel?</title>
+ <para>It's not possible to place tabs upright in the tabPanel. For this
+ purporse it's necessary to use togglePanel. Toggle controls can be
+ placed anywhere in the layout.</para>
+ </section>
+
</chapter>
17 years, 6 months