0

I am using the a ViewStack controlled with visibility of selected NavigatorContent being dependent on user selection of an option from a drop down menu.

enter image description here

Each View of the ViewStack has its own separate UI elements including 2-3 DataGrid, charts etc - think of it as a simple school application where each view binds to a course and shows performance of students for that course (while listing students in grid)

Sometimes, there is a problem with showing the data though - before the Rendering completes, the data is ready to be populated; this throws a null exception as the UI element where the data needs to be populated has not been created yet.

For this, I made the 'creationPolicy' set to 'all'. All works just fine after this property is set. But there certainly are tonnes of performance issues:-

  1. Even if the user never ever visits beyond the 1st visible view, the other views do get rendered (UI elements initialized and created).
  2. Performance hit at startup - startup time is large and grows with the number of views I have (right now I have 9 views with creationPolicy set to all)!! Application was quick to load when only the 1st view was visible by default and creationPolicy was set to default/auto
  3. UI kind of hangs/becomes unresponsive while application starts (as it all happens in the same thread)

What could be a possible solution to this.

These are the solutions that I had in mind, and which didn't work for a reason or two:-

  • For the first time a view is selected via the dropdown controller (i.e. when the rendering cum UI creation is yet to take place), I can show a preloader or sometime. I tried doing this, but the UI still hangs/becomes unresponsive.
  • CallLater can it help? Not really, as I would still be creating all views even if they are not required.

So, I need an elegant way of displaying the views (and show some sort of progress or loader) when they are created/instantiated.

Update

I get the Null errors when there is a sort of race condition - when the processing (which returns data to be filled into UI components, lets say a grid) completes before the rendering of the UI element completes - I have recognized why it happens. Initially, I had creationPolicy set to default, so whenever I use to select a view, it was created at that time; and in case the data to be populated was returned before the elements of the view were created there were null pointer (as the UI element I use to refer to were still be created and thus were null at that instance). Now I am being forced to set the creationPolicy to all so that UI is created for all views and I fire the data processing on selection of that view from the dropdown.

What I'd rather like to do is to have a way to create the UI on demand (and not all of the UI even if it is not being used).

4

2 回答 2

3

也许您不应该让数据处理推送结果,但反之亦然,一旦 UI 控件准备就绪,是否让 UI 从模型中提取数据?

例如,让数据驻留在绑定到 DataGrid 的 ArrayCollections 中。这样一来,谁先完成并不重要。数据生成器甚至不必知道是谁或在哪里显示它,一旦 ArrayCollection 发出数据已更改的信号,UI 就会显示数据。

于 2013-08-25T13:11:52.393 回答
1

我建议您使用模块而不是视图堆栈。

当使用模块时,会创建单独swf的文件,而不是在加载应用程序时加载。moduleloader.load(module)模块文件只有在通过方法调用时才会被加载。

于 2013-09-03T10:51:52.297 回答