Author: nbelaevski
Date: 2008-01-25 19:00:01 -0500 (Fri, 25 Jan 2008)
New Revision: 5654
Modified:
branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java
Log:
Changes from r5207 reverted
Modified:
branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java
===================================================================
---
branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java 2008-01-25
23:36:59 UTC (rev 5653)
+++
branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/component/UIDataAdaptor.java 2008-01-26
00:00:01 UTC (rev 5654)
@@ -23,12 +23,10 @@
import java.io.IOException;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -808,11 +806,7 @@
* Saved values of {@link EditableValueHolder} fields per iterations.
*/
private Map childState;
-
- private List allDataChildren = null;
- private List editableDataChildren = null;
-
/**
* @param faces
* @return Saved values of {@link EditableValueHolder} fields per
@@ -832,30 +826,19 @@
}
/**
- * Save values of {@link EditableValueHolder} fields before change
- * current row.
+ * Save values of {@link EditableValueHolder} fields before change current
+ * row.
*
* @param faces
*/
- protected void saveChildState(FacesContext faces) {
- Map childState = this.getChildState(faces);
- if (null == editableDataChildren) {
- allDataChildren = new ArrayList();
- editableDataChildren = new ArrayList();
- Iterator itr = dataChildren();
- while (itr.hasNext()) {
- this
- .saveChildState(faces, (UIComponent) itr.next(),
- childState);
- }
+ protected void saveChildState(FacesContext faces) {
- } else {
- for (Iterator c = editableDataChildren.iterator(); c.hasNext();) {
- UIComponent child = (UIComponent) c.next();
- populateChildState(faces, child, childState);
- }
+ Iterator itr = dataChildren();
+ while (itr.hasNext()) {
+ Map childState = this.getChildState(faces);
+ this.saveChildState(faces, (UIComponent) itr.next(), childState);
+ }
}
- }
/**
* Recursive method for Iterate on children for save
@@ -867,10 +850,15 @@
*/
private void saveChildState(FacesContext faces, UIComponent c,
Map childState) {
- allDataChildren.add(c);
- if (c instanceof EditableValueHolder ) {
- populateChildState(faces, c, childState);
- editableDataChildren.add(c);
+
+ if (c instanceof EditableValueHolder && !c.isTransient()) {
+ String clientId = c.getClientId(faces);
+ SavedState ss = (SavedState) childState.get(clientId);
+ if (ss == null) {
+ ss = new SavedState();
+ childState.put(clientId, ss);
+ }
+ ss.populate((EditableValueHolder) c);
}
// continue hack
@@ -885,52 +873,19 @@
}
/**
- * @param faces
- * @param c
- * @param childState
- */
- private void populateChildState(FacesContext faces, UIComponent c,
- Map childState) {
- String clientId = c.getClientId(faces);
- SavedState ss = (SavedState) childState.get(clientId);
- if (ss == null) {
- ss = new SavedState();
- childState.put(clientId, ss);
- }
- ss.populate((EditableValueHolder) c);
- }
-
- /**
- * Restore values of {@link EditableValueHolder} fields after change
- * current row.
+ * Restore values of {@link EditableValueHolder} fields after change current
+ * row.
*
* @param faces
*/
- protected void restoreChildState(FacesContext faces) {
- Map childState = this.getChildState(faces);
+ protected void restoreChildState(FacesContext faces) {
- if (null == editableDataChildren) {
- allDataChildren = new ArrayList();
- editableDataChildren = new ArrayList();
- Iterator itr = dataChildren();
- while (itr.hasNext()) {
- this.restoreChildState(faces, (UIComponent) itr.next(),
- childState);
- }
-
- } else {
- for (Iterator c = allDataChildren.iterator(); c.hasNext();) {
- UIComponent child = (UIComponent) c.next();
- // reset id
- String id = child.getId();
- child.setId(id);
- }
- for (Iterator c = editableDataChildren.iterator(); c.hasNext();) {
- UIComponent child = (UIComponent) c.next();
- applyChildState(faces, child, childState);
- }
+ Iterator itr = dataChildren();
+ while (itr.hasNext()) {
+ Map childState = this.getChildState(faces);
+ this.restoreChildState(faces, (UIComponent) itr.next(), childState);
+ }
}
- }
/**
* Recursive part of
@@ -946,11 +901,17 @@
// reset id
String id = c.getId();
c.setId(id);
- allDataChildren.add(c);
+
// hack
if (c instanceof EditableValueHolder) {
- applyChildState(faces, c, childState);
- editableDataChildren.add(c);
+ EditableValueHolder evh = (EditableValueHolder) c;
+ String clientId = c.getClientId(faces);
+ SavedState ss = (SavedState) childState.get(clientId);
+ if (ss != null) {
+ ss.apply(evh);
+ } else {
+ NullState.apply(evh);
+ }
}
// continue hack
@@ -965,23 +926,6 @@
}
/**
- * @param faces
- * @param c
- * @param childState
- */
- private void applyChildState(FacesContext faces, UIComponent c,
- Map childState) {
- EditableValueHolder evh = (EditableValueHolder) c;
- String clientId = c.getClientId(faces);
- SavedState ss = (SavedState) childState.get(clientId);
- if (ss != null) {
- ss.apply(evh);
- } else {
- NullState.apply(evh);
- }
- }
-
- /**
* Check for validation errors on children components. If true, saved values
* must be keep on render phase
*
@@ -1112,8 +1056,6 @@
public void encodeBegin(FacesContext context) throws IOException {
resetDataModel();
- this.editableDataChildren = null;
- this.allDataChildren = null;
if (!keepSaved(context)) {
childState.remove(getBaseClientId(context));
}
Show replies by date