You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mb...@apache.org on 2005/08/03 16:46:59 UTC
svn commit: r227231 - in /myfaces:
api/trunk/src/java/javax/faces/component/UIData.java
tomahawk/trunk/src/java/org/apache/myfaces/component/html/ext/HtmlDataTableHack.java
Author: mbr
Date: Wed Aug 3 07:46:50 2005
New Revision: 227231
URL: http://svn.apache.org/viewcvs?rev=227231&view=rev
Log:
EditableValueHolder states of column facets should not be saved/restored for each row.
Thanks to Mathias Werlitz who reported it.
Modified:
myfaces/api/trunk/src/java/javax/faces/component/UIData.java
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/ext/HtmlDataTableHack.java
Modified: myfaces/api/trunk/src/java/javax/faces/component/UIData.java
URL: http://svn.apache.org/viewcvs/myfaces/api/trunk/src/java/javax/faces/component/UIData.java?rev=227231&r1=227230&r2=227231&view=diff
==============================================================================
--- myfaces/api/trunk/src/java/javax/faces/component/UIData.java (original)
+++ myfaces/api/trunk/src/java/javax/faces/component/UIData.java Wed Aug 3 07:46:50 2005
@@ -131,15 +131,15 @@
{
if (_initialDescendantComponentState == null)
{
- _initialDescendantComponentState = saveDescendantComponentStates(getChildren()
- .iterator());
+ _initialDescendantComponentState = saveDescendantComponentStates(
+ getChildren().iterator(), false);
}
}
else
{
_rowStates.put(getClientId(facesContext),
- saveDescendantComponentStates(getChildren()
- .iterator()));
+ saveDescendantComponentStates(getChildren().iterator(),
+ false));
}
_rowIndex = rowIndex;
@@ -163,12 +163,12 @@
{
Object rowData = dataModel.getRowData();
facesContext.getExternalContext().getRequestMap().put(var,
- rowData);
+ rowData);
}
else
{
facesContext.getExternalContext().getRequestMap().remove(
- var);
+ var);
}
}
}
@@ -176,7 +176,7 @@
if (_rowIndex == -1)
{
restoreDescendantComponentStates(getChildren().iterator(),
- _initialDescendantComponentState);
+ _initialDescendantComponentState, false);
}
else
{
@@ -184,18 +184,18 @@
if (rowState == null)
{
restoreDescendantComponentStates(getChildren().iterator(),
- _initialDescendantComponentState);
+ _initialDescendantComponentState, false);
}
else
{
restoreDescendantComponentStates(getChildren().iterator(),
- rowState);
+ rowState, false);
}
}
}
private void restoreDescendantComponentStates(Iterator childIterator,
- Object state)
+ Object state, boolean restoreChildFacets)
{
Iterator descendantStateIterator = null;
while (childIterator.hasNext())
@@ -210,7 +210,7 @@
Object childState = null;
Object descendantState = null;
if (descendantStateIterator != null
- && descendantStateIterator.hasNext())
+ && descendantStateIterator.hasNext())
{
Object[] object = (Object[]) descendantStateIterator.next();
childState = object[0];
@@ -219,14 +219,24 @@
if (component instanceof EditableValueHolder)
{
((EditableValueHolderState) childState)
- .restoreState((EditableValueHolder) component);
+ .restoreState((EditableValueHolder) component);
}
- restoreDescendantComponentStates(component.getFacetsAndChildren(),
- descendantState);
+ Iterator childsIterator;
+ if (restoreChildFacets)
+ {
+ childsIterator = component.getFacetsAndChildren();
+ }
+ else
+ {
+ childsIterator = component.getChildren().iterator();
+ }
+ restoreDescendantComponentStates(childsIterator, descendantState,
+ true);
}
}
- private Object saveDescendantComponentStates(Iterator childIterator)
+ private Object saveDescendantComponentStates(Iterator childIterator,
+ boolean saveChildFacets)
{
Collection childStates = null;
while (childIterator.hasNext())
@@ -236,15 +246,24 @@
childStates = new ArrayList();
}
UIComponent child = (UIComponent) childIterator.next();
- Object descendantState = saveDescendantComponentStates(child
- .getFacetsAndChildren());
+ Iterator childsIterator;
+ if (saveChildFacets)
+ {
+ childsIterator = child.getFacetsAndChildren();
+ }
+ else
+ {
+ childsIterator = child.getChildren().iterator();
+ }
+ Object descendantState = saveDescendantComponentStates(
+ childsIterator, true);
Object state = null;
if (child instanceof EditableValueHolder)
{
state = new EditableValueHolderState(
- (EditableValueHolder) child);
+ (EditableValueHolder) child);
}
- childStates.add(new Object[] {state, descendantState});
+ childStates.add(new Object[] { state, descendantState });
}
return childStates;
}
@@ -304,7 +323,7 @@
if (event instanceof FacesEventWrapper)
{
FacesEvent originalEvent = ((FacesEventWrapper) event)
- .getWrappedFacesEvent();
+ .getWrappedFacesEvent();
int eventRowIndex = ((FacesEventWrapper) event).getRowIndex();
int currentRowIndex = getRowIndex();
setRowIndex(eventRowIndex);
@@ -419,7 +438,7 @@
continue;
}
for (Iterator facetsIter = child.getFacets().values()
- .iterator(); facetsIter.hasNext();)
+ .iterator(); facetsIter.hasNext();)
{
UIComponent facet = (UIComponent) facetsIter.next();
process(context, facet, processAction);
@@ -457,10 +476,10 @@
continue;
}
for (Iterator columnChildIter = child.getChildren()
- .iterator(); columnChildIter.hasNext();)
+ .iterator(); columnChildIter.hasNext();)
{
UIComponent columnChild = (UIComponent) columnChildIter
- .next();
+ .next();
process(context, columnChild, processAction);
}
}
@@ -470,19 +489,19 @@
}
private void process(FacesContext context, UIComponent component,
- int processAction)
+ int processAction)
{
switch (processAction)
{
- case PROCESS_DECODES:
- component.processDecodes(context);
- break;
- case PROCESS_VALIDATORS:
- component.processValidators(context);
- break;
- case PROCESS_UPDATES:
- component.processUpdates(context);
- break;
+ case PROCESS_DECODES:
+ component.processDecodes(context);
+ break;
+ case PROCESS_VALIDATORS:
+ component.processValidators(context);
+ break;
+ case PROCESS_UPDATES:
+ component.processUpdates(context);
+ break;
}
}
@@ -545,7 +564,7 @@
private int _rowIndex;
public FacesEventWrapper(FacesEvent facesEvent, int rowIndex,
- UIData redirectComponent)
+ UIData redirectComponent)
{
super(redirectComponent);
_wrappedFacesEvent = facesEvent;
@@ -631,7 +650,7 @@
if (obj == null)
return; //Clearing is allowed
throw new UnsupportedOperationException(this.getClass().getName()
- + " UnsupportedOperationException");
+ + " UnsupportedOperationException");
}
};
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/ext/HtmlDataTableHack.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/ext/HtmlDataTableHack.java?rev=227231&r1=227230&r2=227231&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/ext/HtmlDataTableHack.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/component/html/ext/HtmlDataTableHack.java Wed Aug 3 07:46:50 2005
@@ -153,14 +153,14 @@
if (_initialDescendantComponentState == null)
{
_initialDescendantComponentState = saveDescendantComponentStates(getChildren()
- .iterator());
+ .iterator(), false);
}
}
else
{
_rowStates.put(getClientId(facesContext),
saveDescendantComponentStates(getChildren()
- .iterator()));
+ .iterator(), false));
}
_rowIndex = rowIndex;
@@ -197,7 +197,7 @@
if (_rowIndex == -1)
{
restoreDescendantComponentStates(getChildren().iterator(),
- _initialDescendantComponentState);
+ _initialDescendantComponentState, false);
}
else
{
@@ -205,18 +205,18 @@
if (rowState == null)
{
restoreDescendantComponentStates(getChildren().iterator(),
- _initialDescendantComponentState);
+ _initialDescendantComponentState, false);
}
else
{
restoreDescendantComponentStates(getChildren().iterator(),
- rowState);
+ rowState, false);
}
}
}
- protected void restoreDescendantComponentStates(Iterator childIterator,
- Object state)
+ private void restoreDescendantComponentStates(Iterator childIterator,
+ Object state, boolean restoreChildFacets)
{
Iterator descendantStateIterator = null;
while (childIterator.hasNext())
@@ -231,7 +231,7 @@
Object childState = null;
Object descendantState = null;
if (descendantStateIterator != null
- && descendantStateIterator.hasNext())
+ && descendantStateIterator.hasNext())
{
Object[] object = (Object[]) descendantStateIterator.next();
childState = object[0];
@@ -240,14 +240,24 @@
if (component instanceof EditableValueHolder)
{
((EditableValueHolderState) childState)
- .restoreState((EditableValueHolder) component);
+ .restoreState((EditableValueHolder) component);
}
- restoreDescendantComponentStates(component.getFacetsAndChildren(),
- descendantState);
+ Iterator childsIterator;
+ if (restoreChildFacets)
+ {
+ childsIterator = component.getFacetsAndChildren();
+ }
+ else
+ {
+ childsIterator = component.getChildren().iterator();
+ }
+ restoreDescendantComponentStates(childsIterator, descendantState,
+ true);
}
}
- protected Object saveDescendantComponentStates(Iterator childIterator)
+ private Object saveDescendantComponentStates(Iterator childIterator,
+ boolean saveChildFacets)
{
Collection childStates = null;
while (childIterator.hasNext())
@@ -257,15 +267,24 @@
childStates = new ArrayList();
}
UIComponent child = (UIComponent) childIterator.next();
- Object descendantState = saveDescendantComponentStates(child
- .getFacetsAndChildren());
+ Iterator childsIterator;
+ if (saveChildFacets)
+ {
+ childsIterator = child.getFacetsAndChildren();
+ }
+ else
+ {
+ childsIterator = child.getChildren().iterator();
+ }
+ Object descendantState = saveDescendantComponentStates(
+ childsIterator, true);
Object state = null;
if (child instanceof EditableValueHolder)
{
state = new EditableValueHolderState(
- (EditableValueHolder) child);
+ (EditableValueHolder) child);
}
- childStates.add(new Object[] {state, descendantState});
+ childStates.add(new Object[] { state, descendantState });
}
return childStates;
}