新手请教一个关于cairngorm的问题
我对 Flex 非常陌生(几天前开始学习),现在我对如何使用 Flex 创建用户界面以及如何使用 Cairngorm 进行 MVC 有了一些了解,并且我真的开始喜欢它。但我仍然对使用 Cairngorm 或完全在 Flex 中改变视图感到困惑。作为一名超过 10 年的 Java/J2EE 开发人员,它帮助我理解与 Java 相比的新技术。通常在 java 世界或任何 MVC 框架中,控制器一旦获得更新的模式,就会重定向或设置新视图给用户。比方说,一旦我向电影数据库添加了一部新电影,我想向用户展示一个视图电影屏幕,当他删除电影时,我想让用户看到所有电影的列表。到目前为止我看到的示例(包括图表资源管理器)只是更改模态值,并且数据在同一视图中更新(使用 [Bindable]
),但我的问题是如何更改视图取决于结果
,或者如果它是错误
,我想将用户带到不同的屏幕。如何在 Flex 和 Cairngorm 中做到这一点。是否有任何可用的最佳实践,请有人指出我正确的方向/资源。提前致谢。
I am very new to Flex (started learning a couple of days back), I now have some understanding on how to create user interfaces with Flex and how to do MVC with Cairngorm and I really started liking it. But I am still lost with changing views using Cairngorm or entirely in Flex. Being a Java/J2EE developer for more than 10 years, it helps me understanding new technologies comparing it with Java. Typically in java world or in any MVC framework, the controller once got the updated modal it redirects or sets the new view to the user. Lets say once I added a new movie to movie database, I want to show the user a view Movie screen and when he deletes a movie I want to take user to list of all movies. The example which I have seen so far(including the diagram explorer) are just changing the modal values and the data is updating in the same view (using [Bindable]
), but my question is how to change the view depending on the result
or if it's a fault
I want to take user to a different screen. How to do that in flex and in Cairngorm. Are there any best practices available and somebody please point me to right direction/resource. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 Cairngorm 执行此操作的常用方法是将有关应用程序状态的数据(例如用户所在的屏幕)也放入模型中。例如,您可以使用
ViewStack
作为应用程序不同部分的主容器,并将其selectedIndex
绑定到模型中的一个变量,该变量将用于控制显示给用户的屏幕。简而言之 - 应用程序的状态是模型的反映。The usual way to do this with Cairngorm is to put the data about the state of the application (eg. the screen the user is on) in the model too. You can, for example, use the
ViewStack
as the main container of the different parts of your application and bind it'sselectedIndex
to a variable in the model which will be used to control the screen that is displayed to the user. Putting it shortly - the state of the application is a reflection of the model.您可能还想查看 Mate 框架。我们最近在使用 Cairngorm 后转向 Mate,因为我们发现它是一个更容易使用和理解的框架。
对于您的示例,您将有一个
faultHandler
事件侦听器,它将调用您模型中所需的任何方法。您可以轻松地使用它来显示或隐藏您需要的任何内容。You may also want to take a look at the Mate framework. We recently switched to Mate after using Cairngorm because we found it was a much easier framework to use and understand.
For your example, you would have a
faultHandler
event listener that would call whatever method you wanted in your model. You could easily use that to show or hide whatever you needed to.