Will do. Thanks.
John Fan
On 6/27/06, Adam Winer <[EMAIL PROTECTED]> wrote:
Erm, I think you mean "org.apache.myfaces.adf.component.ChildArrayList"...
But, yes, I agree; could you file an issue and create a patch? Also,
if you could add a new testcase to
org.apache.myfaces.adf.component.AddRemoveTest
to expose this problem and verify the fix, that'd be great.
-- Adam
On 6/27/06, Qiang Fan <[EMAIL PROTECTED]> wrote:
>
> Some one reported an issue related to
> oracle.adf.view.rich.component.ChildArrayList class in Trinidad.
>
> Here is the code in the add(int index, Object element) method in
> 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 issue is:
>
> int adjustedIndex = index;
> Object oldParent = child.getParent();
> if (oldParent != null)
> {
> adjustedIndex = __removeFromParent(child, index);
> if(oldParent == _parent)
> {
> index = adjustedIndex; //Only make the index adjustment when
the
> child is re-added to the same parent
> }
> }
> child.setParent(_parent);
> super.add(index, child);
>
> I'd like to get your comment. If every one agrees to make this change, I
> will create a patch.
>
> Thanks!
>
> John Fan
>
>