1 Reply Latest reply on Dec 15, 2009 12:00 PM by PhilipKeiter

    Problem in Presentation Models updating the views


      Hello all


      I am trying to create a login screen using presentation model and cairngorm. I have created a main screen which includes two components - login screen and member screen. They get displayed depending on login process. The problem is that even after sucessful login - I cannot get the view to update.


      I know the reason - because I am creating two instances of  Presentation model for Main.mxml in Main.mxml as well as the presentation model for it.


      // Presentation model for Main.mxml
      public class MainModel {
           public var prop:String;
           public function callbackFunc( value:String ) {
                prop = value;


      // Presentation model for Login.mxml
      public class LoginModel {
           public function doLogin( username:String, password:String ) {
                var mainModel:MainModel = new MainModel(); // Instance created
                var event:LoginEvent = new LoginEvent( mainModel.callbackFunc, username, password );


      <!-- Main.mxml -->
           public var model:MainModel = new MainModel(); // Another instance created
      <mx:ViewStack id="views" selectedIndex="{model.prop}">
           <views:MemberScreen />
           <views:Login />


      <!-- Login.mxml -->
           public var model:LoginModel = new LoginModel();
      <!-- form elements here -->
      <mx:Button label="login" id="btnLogin" click="{model.doLogin( 'abc', 'def' )}" />


      In this scenario, I am making use to the callback function for the view to get updated when the loginEvent gets triggered. But the view does not get updated because of two separate instances.


      How should I exploit the presentation model pattern in this scenario along with callback functions?


      Thanks and Regards