[richfaces-svn-commits] JBoss Rich Faces SVN: r5073 - trunk/ui/columns/src/main/java/org/richfaces/taglib.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Fri Dec 28 09:11:56 EST 2007
Author: andrei_exadel
Date: 2007-12-28 09:11:56 -0500 (Fri, 28 Dec 2007)
New Revision: 5073
Modified:
trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsTag.java
Log:
Dynamic columns refactoring
Modified: trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsTag.java
===================================================================
--- trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsTag.java 2007-12-28 14:04:47 UTC (rev 5072)
+++ trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsTag.java 2007-12-28 14:11:56 UTC (rev 5073)
@@ -36,12 +36,16 @@
* @author "Andrey Markavtsov"
*
*/
-public class ColumnsTag extends UIComponentClassicTagBase
- implements IterationTag {
+public class ColumnsTag extends UIComponentClassicTagBase implements
+ IterationTag {
+ /** Component type */
private static final String COLUMN_COMPONENT_TYPE = UIColumn.COMPONENT_TYPE;
- /** Current column counter */
+ /** Prefix before id to be assigned for column */
+ private static final String COLUMN_ID_PREFIX = "rf";
+
+ /** Current column counter */
private Integer index = -1;
/** Data table */
@@ -93,6 +97,9 @@
/** Expression for var item */
private IteratedExpression iteratedExpression;
+ /** Column incrementer */
+ private Integer counter = 0;
+
/**
* <p>
* The <code>Lst</code> of {@link UIComponent} ids created or located by
@@ -259,7 +266,7 @@
public void setHeaderClass(ValueExpression __headerClass) {
this._headerClass = __headerClass;
}
-
+
/**
* rowspan Corresponds to the HTML rowspan attribute
*/
@@ -502,12 +509,16 @@
}
UIComponent component = createColumn();
pushUIComponentClassicTagBase(this);
-
+
dataTable.getChildren().add(component);
next();
}
+ private String generateColumnId() {
+ return COLUMN_ID_PREFIX + Integer.toString(counter++);
+ }
+
/**
* Creates column instance
*
@@ -516,7 +527,7 @@
private UIComponent createColumn() {
UIComponent component = getFacesContext().getApplication()
.createComponent(COLUMN_COMPONENT_TYPE);
- component.setId(getFacesContext().getViewRoot().createUniqueId());
+ component.setId(generateColumnId());
initColumnByThis(component);
@@ -554,6 +565,29 @@
return (index == -1);
}
+ /**
+ * Deletes dynamic rich columns created before
+ */
+ private void deleteRichColumns() {
+ List<UIComponent> children = dataTable.getChildren();
+ Iterator<UIComponent> it = children.iterator();
+ List<UIComponent> forDelete = new ArrayList<UIComponent>();
+ Integer i = 0;
+ while (it.hasNext()) {
+ UIComponent child = it.next();
+ String id = child.getId();
+ if (id != null && id.startsWith(COLUMN_ID_PREFIX)) {
+ forDelete.add(child);
+ }
+ i++;
+ }
+ it = forDelete.iterator();
+ while (it.hasNext()) {
+ UIComponent elem = it.next();
+ children.remove(elem);
+ }
+ }
+
/*
* (non-Javadoc)
*
@@ -565,7 +599,7 @@
prepare();
if (created) {
- dataTable.getChildren().clear();
+ deleteRichColumns();
created = false;
}
@@ -995,4 +1029,3 @@
}
}
-
More information about the richfaces-svn-commits
mailing list