高级数据网格:错误:书签不再有效

发布于 2024-10-05 03:48:19 字数 3255 浏览 6 评论 0原文

我正在研究高级数据网格的缩进和减少。我有一组函数,这些函数在对底层数据进行操作时可以正常工作,但在对数据网格的选定项目进行操作时会抛出“错误:书签不再有效”。

当我运行此代码时,它运行良好:

indentLeaf(l5)
outdentLeaf(l4)

但此代码失败:

adg.selectedItem = l5
indentLeaf(adg.selectedItem as Leaf)
adg.selectedItem = l4
outdentLeaf(adg.selectedItem as Leaf)

该代码并非在所有实例中都会失败,仅适用于数据网格数据树的某些配置。

如果您想看到抛出的错误,则需要在 Flash 播放器的调试器版本中运行代码。我已将遇到的错误剪切并粘贴到文本区域中以供参考,如下所示。

当抛出异常时,玩具应用程序中的代码似乎可以正常恢复,但在我的较大应用程序中,它会导致严重崩溃。

打开查看源代码后,可以在此处找到示例代码:http://www.crcarlson.com/adg/ADGArrayCollectionUpdate.swf

要创建错误,请重置树,然后单击“indent/outdent2”

我将不胜感激任何关于如何解决这个问题的建议。

完整的堆栈跟踪如下所示:

Error: Bookmark no longer valid.
at ListCollectionViewCursor/seek()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:2417]
at mx.collections::HierarchicalCollectionViewCursor/get current()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\HierarchicalCollectionViewCursor.as:220]
at mx.collections::HierarchicalCollectionViewCursor/collectionChangeHandler()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\HierarchicalCollectionViewCursor.as:1143]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::HierarchicalCollectionView/nestedCollectionChangeHandler()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\HierarchicalCollectionView.as:1595]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::ListCollectionView/dispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1024]
at mx.collections::ListCollectionView/handlePropertyChangeEvents()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1433]
at mx.collections::ListCollectionView/listChangeHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1300]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::ArrayList/internalDispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ArrayList.as:673]
at mx.collections::ArrayList/itemUpdateHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ArrayList.as:704]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at Leaf/dispatchChildrenChanged()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\Leaf.as:119]
at Leaf/addChildAt()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\Leaf.as:63]
at Leaf/move()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\Leaf.as:96]
at ADGArrayCollectionUpdate/outdentLeaf()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\ADGArrayCollectionUpdate.mxml:86]
at ADGArrayCollectionUpdate/IO2_clickHandler()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\ADGArrayCollectionUpdate.mxml:113]
at ADGArrayCollectionUpdate/__IO2_click()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\ADGArrayCollectionUpdate.mxml:183]

I am working on an indent and outdent for the advanced datagrid. I have a set of functions which work when operating on the underlying data fine, but which throw "Error: Bookmark no longer valid" when operating on the selected items of the datagrid.

When I run this code it runs fine:

indentLeaf(l5)
outdentLeaf(l4)

But this code fails:

adg.selectedItem = l5
indentLeaf(adg.selectedItem as Leaf)
adg.selectedItem = l4
outdentLeaf(adg.selectedItem as Leaf)

The code does not fail in all instances, only for some configurations of the data grid data tree.

The code needs to be run in the debugger version of the flash player if you want to see the error thrown. I have cut and pasted the error I get into the text area for reference as well as below.

The code in the toy app seems to recover ok when the exception is thrown, but in my larger app it leads to hard crashes.

Example code can be found here with view source turned on: http://www.crcarlson.com/adg/ADGArrayCollectionUpdate.swf

To create the error, reset the tree and then click "indent/outdent2"

I would appreciate any suggestions on how to get around this.

The full stack trace looks like this:

Error: Bookmark no longer valid.
at ListCollectionViewCursor/seek()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:2417]
at mx.collections::HierarchicalCollectionViewCursor/get current()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\HierarchicalCollectionViewCursor.as:220]
at mx.collections::HierarchicalCollectionViewCursor/collectionChangeHandler()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\HierarchicalCollectionViewCursor.as:1143]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::HierarchicalCollectionView/nestedCollectionChangeHandler()[E:\dev\4.x\frameworks\projects\datavisualization\src\mx\collections\HierarchicalCollectionView.as:1595]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::ListCollectionView/dispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1024]
at mx.collections::ListCollectionView/handlePropertyChangeEvents()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1433]
at mx.collections::ListCollectionView/listChangeHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:1300]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.collections::ArrayList/internalDispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ArrayList.as:673]
at mx.collections::ArrayList/itemUpdateHandler()[E:\dev\4.x\frameworks\projects\framework\src\mx\collections\ArrayList.as:704]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at Leaf/dispatchChildrenChanged()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\Leaf.as:119]
at Leaf/addChildAt()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\Leaf.as:63]
at Leaf/move()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\Leaf.as:96]
at ADGArrayCollectionUpdate/outdentLeaf()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\ADGArrayCollectionUpdate.mxml:86]
at ADGArrayCollectionUpdate/IO2_clickHandler()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\ADGArrayCollectionUpdate.mxml:113]
at ADGArrayCollectionUpdate/__IO2_click()[C:\adobeFlexTraining\_workspace\ADGArrayCollectionUpdate\src\ADGArrayCollectionUpdate.mxml:183]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蛮可爱 2024-10-12 03:48:19

我刚刚找到了解决此错误的方法(我使用的是 SDK 3.5,但我猜 4.1 的修复将非常相同)。问题出在 HierarchicalCollectionViewCursor 类的“current()”getter 中。

它不会捕获由无效书签引起的 CursorError。

步骤 1 是创建一个更好的光标类:

public class HierarchicalCollectionViewCursor2 extends HierarchicalCollectionViewCursor
{
    public function HierarchicalCollectionViewCursor2(collection:HierarchicalCollectionView, model:ICollectionView, hierarchicalData:IHierarchicalData)
    {
        super(collection, model, hierarchicalData);
    }


    override public function get current() : Object
    {
        // original HierarchicalCollectionViewCursor class fails to catch the "bookmark no
        // longer valid" Error, which is thrown as a CollectionViewError instance in ListCollectionView,
        // but transformed to a CursorError within the same class
        try {
            var result:Object = super.current;
        }
        catch (e:CursorError) {
            result = null;
        }

        // done
        return result;
    }
}

步骤 2 是创建一个 HierarchicalCollectionView 类,它返回新的光标:

use namespace mx_internal;

public class HierarchicalCollectionView2 extends HierarchicalCollectionView
{
    public function HierarchicalCollectionView2(hierarchicalData:IHierarchicalData=null, argOpenNodes:Object=null)
    {
        super(hierarchicalData, argOpenNodes);
    }


    override public function createCursor() : IViewCursor
    {
        return new HierarchicalCollectionViewCursor2(this, treeData, this.source);
    }
}

步骤 3 是实际使用新的 HierarchicalCollectionView2 类作为数据提供者。

var itemsAC:ArrayCollection = new ArrayCollection();
// add items etc
this.adgDataProvider = new HierarchicalCollectionView2(new HierarchicalData(itemsAC));

现在您可能会认为一切都很好,但如果没有另一个烦人的 Flex-SDK bug,戏剧就不会完整。在本例中为:

https://bugs.adobe.com/jira/browse/FLEXDMV- 1846 章

就是这样——对我有用!

I just found a workaround for this bug (I am using SDK 3.5 but I guess a 4.1 fix would be very much the same). The problem lies within the "current()" getter of the HierarchicalCollectionViewCursor class.

It doesn't catch the CursorError that's caused by an invalid bookmark.

Step 1 is to create a better cursor class:

public class HierarchicalCollectionViewCursor2 extends HierarchicalCollectionViewCursor
{
    public function HierarchicalCollectionViewCursor2(collection:HierarchicalCollectionView, model:ICollectionView, hierarchicalData:IHierarchicalData)
    {
        super(collection, model, hierarchicalData);
    }


    override public function get current() : Object
    {
        // original HierarchicalCollectionViewCursor class fails to catch the "bookmark no
        // longer valid" Error, which is thrown as a CollectionViewError instance in ListCollectionView,
        // but transformed to a CursorError within the same class
        try {
            var result:Object = super.current;
        }
        catch (e:CursorError) {
            result = null;
        }

        // done
        return result;
    }
}

Step 2 is to create a HierarchicalCollectionView class, which returns that new cursor:

use namespace mx_internal;

public class HierarchicalCollectionView2 extends HierarchicalCollectionView
{
    public function HierarchicalCollectionView2(hierarchicalData:IHierarchicalData=null, argOpenNodes:Object=null)
    {
        super(hierarchicalData, argOpenNodes);
    }


    override public function createCursor() : IViewCursor
    {
        return new HierarchicalCollectionViewCursor2(this, treeData, this.source);
    }
}

Step 3 is to actually use that new HierarchicalCollectionView2 class as your data-provider.

var itemsAC:ArrayCollection = new ArrayCollection();
// add items etc
this.adgDataProvider = new HierarchicalCollectionView2(new HierarchicalData(itemsAC));

Now you would think that all is well BUT the drama wouldn't be complete without another annoying Flex-SDK bug. In this case its:

https://bugs.adobe.com/jira/browse/FLEXDMV-1846

So, Step 4 is to subclass the AdvancedDataGrid component as described in the bug issue.

That's it -- works for me!

记忆消瘦 2024-10-12 03:48:19

此异常可能发生在具有 HierarchicalData 的 Flex AdvancedDatagrid 中。
当项目添加到 Dataprovider 时,它会通知 datagrid 。每次向数据网格添加项目时,数据网格都会收到集合更改事件。然后一些数据网格内部可能会变得混乱。
您可以禁用自动 ArayCollecion 刷新:

    dataprovider.disableAutoUpdate();

当您的数据网格准备好使用刷新数据网格渲染时:

    if (advancedDataGrid) {
            advancedDataGrid.invalidateList();
            advancedDataGrid.invalidateDisplayList();
            advancedDataGrid.expandAll();
        }

我希望这会有所帮助。

This Exeption may hapen in Flex AdvancedDatagrid with HierarchicalData.
When items are added to Dataprovider it notifies the datagrid . the datagrid receives colection change events each time items are added to it.then some Datagrid internal can be messed up .
You could disable the automatic ArayCollecion refresh :

    dataprovider.disableAutoUpdate();

and when you datagrid is ready to use refresh datagrid rendering :

    if (advancedDataGrid) {
            advancedDataGrid.invalidateList();
            advancedDataGrid.invalidateDisplayList();
            advancedDataGrid.expandAll();
        }

I hope this will help.

迷途知返 2024-10-12 03:48:19

Sami 关于(HierarchicalCollectionViewCursor)内部结构变得混乱的说法是正确的。这是 Flex 框架中最长期存在的错误之一。最近在 FLEX-34119 及其所有链接中记录并修复了该问题门票。它应该在 Flex SDK 4.14 中可用,这意味着从那时起不需要任何解决方法。

Sami was right about the internals (of HierarchicalCollectionViewCursor) getting messed up. This was one of the most long-standing bugs in the Flex framework. It was recently documented - and fixed - at FLEX-34119 and all its linked tickets. It should be available in Flex SDK 4.14, which means that no workaround will be needed from that point onward.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文