You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-issues@incubator.apache.org by "Adam Winer (JIRA)" <ad...@incubator.apache.org> on 2006/06/30 21:48:31 UTC
[jira] Assigned: (ADFFACES-41) Children out of order in
ChildArrayList when re-added to different parent
[ http://issues.apache.org/jira/browse/ADFFACES-41?page=all ]
Adam Winer reassigned ADFFACES-41:
----------------------------------
Assign To: Adam Winer
> Children out of order in ChildArrayList when re-added to different parent
> -------------------------------------------------------------------------
>
> Key: ADFFACES-41
> URL: http://issues.apache.org/jira/browse/ADFFACES-41
> Project: MyFaces ADF-Faces
> Type: Bug
> Environment: All
> Reporter: John Fan
> Assignee: Adam Winer
> Priority: Minor
> Attachments: trunk.patch
>
> Here is the code in the add(int index, Object element) method in org.apache.myfaces.adf.component.ChildArrayList class:
>
> if (child.getParent() != null)
> {
> index = __removeFromParent(child, index);
> }
> child.setParent(_parent);
> super.add(index, child);
>
> What it is trying to do is to add a new child (the child variable in the code) to this ChildArrayList, and automatically detach the new child from its old parent, if exists, by calling __removeFromParent.
>
> If you look into the __removeFromParent() method, you can find out that this chunk of code assumes that the old parent is identical to the new parent it is being added under, and __removeFromParent returns an adjusted index value according to this assumption. This assumption is not always right and this is causing problems.
> One way of fixing this is:
> Object oldParent = child.getParent();
> if (oldParent != null)
> {
> int adjustedIndex = __removeFromParent(child, index);
> //Only adjust the index when the child is re-added to the same parent
> if (oldParent == _parent)
> {
> index = adjustedIndex;
> }
> }
> child.setParent(_parent);
> super.add(index, child);
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira