Problem in update of views presentation models

Hi all

I am trying to create a login using cairngorm screen and presentation model. I created a main screen that has two components - the screen logon and member. They appear according to the connection process. The problem is that even after the successful - connection, I can not update view.

I know why - because I create two instances of presentation model for Main.mxml in Main.mxml and format 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 );
          event.dispatch();
     }
}

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

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

In this scenario, I make use of the callback function to the display to get updated when the loginEvent fires. But the view not updated because of two separate proceedings.

How should I use the presentation model pattern in this scenario, as well as callback functions?

Thanks and greetings

ShiVik

You could do a Singleton to the principal so that way everywhere, you use it, you use the same instance of it. Or if you use the Cairngorm ModelLocator (not that I recommend) has a single instance of the principal and you access anywhere else via the ModelLocator.

Tags: Flex

Similar Questions

  • Problem to update the views by using templates

    Hi all

    I'm trying to implement the model of presentation using Cairngorm in my flex application. I have a problem to update the views using the presentation model.

    Here's what I do.

    1. I am trying to create a login screen.
    2. To store the current of the user logged in ModelLocator, I created a "currentUser" property
    3. My Member information screen (the screen is displayed after successful login) displays the username like this.
      • < mx:Label label = "{memberUI.fullname}" / > "
    4. I created a template, memberUI for Member information screen. It has a property called "name", which stores the full name of the current user.
    5. I created a method in the presentation model called setFullname() which does the work of definition of the fullname property. This function is called in the answering machine for the connection event.

         public function setFullname():void {
              var appModel:AppModelLocator = AppModelLocator.getInstance();
              appModel.currentUser = event.result as UserVO;
              var uim:memberUI = new memberUI();
              uim.fullname = appModel.currentUser.firstname + " " + appModel.currentUser.lastname;
         }
    

    But even when I was able to login, I am unable to display the full name in the view. Why is this happening?

    Can someone tell me what I am doing wrong?

    Thanks and greetings

    ShiVik

    I've seen two approaches to this within the PM + Cairngorm architectures.

    (1) pass a reference of your MP in your Cairngorm event to allow the command / responder call Update with the results of a service. It's an approach simple but tie your orders and the speakers to your PM class, which makes them less versatile.

    (2) have your PM record reminders with your Cairngorm event to allow results to be returned to your MP. Reminders may take the form of event, function references listeners or an object that implements IResponder.

    Unfortunately, I'm not aware of many examples online for this, but the following link to get (2) passing references to functions:

    http://www.allenmanning.com/?p=31

  • I have a problem. Update of Flash Player required you must download and install the latest version of Adobe Flash Player to view this content. but my Flash player is up-to-date. I use ubuntu10.4, firefox 8.0

    I have a problem. Update of Flash Player required you must download and install the latest version of Adobe Flash Player to view this content. but my Flash player is up-to-date. I use ubuntu10.4, firefox 8.0

    You are welcome

  • Problem after update, need help

    Guys, I update my vista Home premium today. But I had my (Synaptics) touchpad problem. This is virtual scrolling does not work. When I open the window mouse (from Control Panel) and go to the "Device settings" tab, then click 'Settings', the windows setting for Synaptics open successfully, but shows only 2 menus: Overview and button (while it should be more, like: tapping, virtual scrolling, etc.).

    I tried uninstalling the driver for the TouchPad and reinstall using the former and most recent driver that I got from internet. But the result is always the same.

    My Question is: what is the problem with my Touch Pad device settings and how to make it right?
    Thank you very much for your help.

    Hi d3m14w,

    Welcome to the Microsoft Forums.

    We would like to get some more information from you to help solve your problem.  You better, please answer the following questions.

    1. who is the computer or the manufacturer of the device and what is the the model number of the computer or device that has problems?

    2. the measures to check the update history: click Start-> Control Panel-> security, and then under Windows Update, click view update history. Check your Windows Update history and in this list, what is the date of the last installed update that has raised questions and made me know the KB numbers or the name of all updates installed recently?

    Sangeeta displayed
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • MVC pattern - update the view

    Here's the scenario. The application is based on the MVC pattern.

    The model reads and stores the data in a database.

    Whenever I clicked on one to save, edit, or delete Viewbutton, the model updates the database without any problems.

    However, I failed to make the model to update the view by using this.subscribers [i] .update () in the notifyChanges of the observer method;

    To improvise, I used the logic very developed to "recreate" view whenever the database is updated. This is why the number of cases is increasing rapidly.

    I need help to update the same instance of the view, without having to "recreate".

    See below the complex logic of the main class that makes me worth:

    Whenever the area add, change or Remove button is clicked, two things happen.

    1: public newData Boolean is set to true.

    2nd: a "refreshData" event is dispatched. In response to the event "refreshData", the database is updated via nodel.updateDatabase ().

    After completing the update of the database, a "dataReady" event is dispatched. In response to the 'dataReady' event, with addChild (view) is executed.

    This results in thousands of instances of the composite view of the child with her children.

    package {}

    import flash.events.EventDispatcher;
    import flash.display.Sprite;
    import flash.display. *;
    import flash.events. *.

    SerializableAttribute public class Main extends Sprite {}

    private var: model;

    public void Main() {}

    model = new Model10Vns();

    model.addEventListener ("refreshData", refreshData);
    model.addEventListener ("dataReady", runStrategy);


    function refreshData(event:Event):void {}
    {if (Model.newData)}
    model.updateDatabase (); Database update
    }
    }


    }
    private void runStrategy(event:Event):void {}
    controller: controller of var = new Controller (model);
    view of var = new View(model,controller);
    addChild (view);
    }

    }
    }

    You cannot use super in an anonymous function.

  • Problem with update iOS 9.3!

    When I try to upgrade to iOS 9.3 he always tells me that I am not connected to the Internet, even though I am if it fails? What is happening with this download, never had this problem before?

    Many users have encountered problems to update their devices, their activation or signing into their account after updating iOS 9.3. Apple is aware of the problem and working on a fix.

    Take a look at these articles for additional information on the issue or adapt:

    If you are unable to activate your iPhone, iPad or iPod touch after installing iOS 9.3 - Apple Support

    If you are unable to activate your iPad 2 (GSM model) update to iOS 9.3If you cannot activate your iPad 2 (GSM model) updated to iOS 9.3

    Apple stops updates iOS 9.3 for iDevices older due to Activation Server Lock growing problems.

  • Problems of updates Windows XP - how to fix the incorrect Windows XP updates KB2633952 keep asking to install?

    Problems of updates Windows XP - how to fix the incorrect Windows XP updates KB2633952 keep asking to install? True, it is that it is already installed on your computer. If hide us, an another previous KB2570791 arises in our updates of Windows and asked to install anything, that it was installed... of the questions repeated and very annoying.  Help, please!

    (Microsoft Answers just sent us message have deleted our previous thread, ask for help!) We are simply not that these problems are problems with Windows XP updates related to DST or not?)

    Nadia. PA supporter said that your computer is hacked. He may be right. I can't weigh because I don't know what led him to this conclusion. If your computer is hijacked, then you should address that more that you need to fix this minor update. However, under the resolution of your problem to update, you can try this:

    Assume Windows XP

    Check the C:\Windows\System32\ directory for the presence of the file tzchange.exe

    If the file is not present or if the version of the file is not 5.1.2600.6171 or newer...

    Download the update appropriate 2633952 for your platform here:

    http://support.Microsoft.com/kb/2633952

    Run with - extract switch (e.g., Start > run > "[path to the downloaded file] \WindowsXP-KB2633952-x86-ENU.exe"-x)

    Of course, replace [path to the downloaded file] with the path to the downloaded file.

    Citations may or may not be required depending on the path. Place the x - out the citations if you use them.

    Choose a location for the extracted files (a new folder is recommended)

    Locate the extracted files. File tzchange.exe you want and copy it into C:\windows\System32

    That rerun Windows Update detection to see if the problem is resolved.

  • Problem with update of Intel for Intel (R) Wifi Link 5100 AGN driver

    Hello

    I have Windows Vista, Office 2007, and when I download the update recommended above makes my Internet become very reliable. Some Web pages is not affected, but some will not work. There is no obvious reason why this is the case for all advice would be greatly appreciated.

    Thank you very much

    Paul

    Hello

    You tell us where you found the recommended update.

    ________________________________________________________

    FYI for Windows updates:

    Microsoft gives sometimes you updates for the 3rd party hardware: graphics, network cards, etc.

    You should only get the latest drivers for them to real hardware manufacturer's website, as Microsoft normally does nor those have the most recent drivers available as Microsoft relies of the 3rd party hardware Manufactuer to provide.

    But unfortunately, the only way to know which is the update of the problem is to install them one by one, until you find the 'wrong' for your installation.

    You can do a system restore to get back until it has been installed (which is NOT the best way to remove an update) or follow this method:

    'Remove an update'

    http://Windows.Microsoft.com/en-us/Windows-Vista/remove-an-update

    When you have found the issue of update of the list of updates which is presented > then right click on the update problem > select Hide update > and it will not be available to you once again

    "How to hide or show an update of Windows Vista"

    http://www.Vistax64.com/tutorials/72491-Windows-Update.html

     

    Here's how to chanage update settings, if you think it is necessary to:

    "Understanding Windows Update and Extras in Windows Vista and Windows 7.

    http://www.bleepingcomputer.com/tutorials/Windows-Vista-updates-and-extras/

    Or the other of these two update settings will give you the chance to see what you want to install through Windows updates;

    Download updates but let me choose whether to install them - if you select this option, Windows will download the updates on your computer, but not install them automatically. If you want to install updates, then you must install them manually. You should only select this option if you have a reason to not install updates automatically. Only advanced users should use this option.

    Check for updates but let me choose whether to download and install them - if you select this option, you'll be alerted when there are new updates available for download and install. You can then choose to download and install the updates that you want. This option should really be reserved for people who know exactly which updates they need, or those who have little access to the Internet.

    But remember you normally only have problems with hardware 3rd party drivers. Other updates are to improve the Performance and security of your system

    See you soon.

  • How can I update the view without freezing?

    Hi all

    I am trying to load more items in a list, as does the Twitter app

    When I want to load more items, I have done the following:

    • I shows Loader
    • I do the networking activity
    • I'm updating the view

    The problem is that the application UI freezes during the stage of "update view" (for 2 or 3 seconds).

    Because I'm not in the main thead element I update the gwendoline in the following way:

    UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {
                    synchronized (UiApplication.getEventLock()) {
                        while (MyList.hasMoreElements()) {
                             ...
                              ScrollableList.add(item);
                              ...
                        }
                         hideLoader();
                    }
                }
            });
    

    Is it possible to update the view without fix it the interface?

    Thanks to you all.

    Welcome to the support forum.

    invokelater enough, you don't have to synchronize the lock of the event.

    I don't know what is ScrollableList, but if you want to use a ListField, for example, you can add all the entries at a time.
    Even in other cases, as a normal Manager, addAll could be much better performance.

  • Problem with update of windows 10

    During the update to windows 10 my laptop has been shutdown, the update to windows 10 now not restart. It ask me to reboot the laptop. What is wrong with him?

    Hello

    Thanks for posting your question in the Microsoft Community.

    I understand that it must be difficult for you, when things do not work as it should. I'm sorry to know that you are facing this problem.

    Please answer these questions to get more clarity on this issue:

    • What is the brand and model of the pc?

    • You have a wired network connection?

    You must first upgrade your pc from Windows 8 to 8.1 Windows and then upgrade to Windows 10. Make sure that the power cable is plugged into the socket so that the laptop does not work on battery power during the update.

    First step, you can run the Windows Update Troubleshooter to check if that helps.

    You will be able to resolve some problems in running a convenience store will automatically fix some common problems with Windows Update.

    http://Windows.Microsoft.com/en-in/Windows/troubleshoot-problems-installing-updates#1TC=Windows-8

    In addition, you can use the ISO for upgrade to Windows 10.

    How to: upgrade from previous versions of Windows using the file ISO for Windows 10: http://answers.microsoft.com/en-us/insider/wiki/insider_wintp-insider_install/how-to-upgrade-from-previous-versions-of-windows/31722b30-1da9-42bb-b331-0edc4649bf43

    Keep us in the loop to help you further.

  • Problem of update & photo Windows 8

    Several times I tried to 'update & Restart' my laptop that takes hours in a row, but starts can you back to say it is impossible to install the updates. I also noticed I can't see pictures in Windows Photo Viewer, or show icons for them. I don't know if it is separate from the update or not, but it's happening both now & I can't seem to find anything to help.

    It is likely that the two issues are interrelated. In this case, it is advisable to run the Windows Update Troubleshooter from the following link and check if this is useful:
    http://Windows.Microsoft.com/en-us/Windows/troubleshoot-problems-installing-updates#1TC=Windows-8

    Hope this will help you.

  • Update App Viewer to v27

    Hello

    I m is a bit confused about the upgrade process. I want to upgrade to the spectator v27 mainly to solve the problem with the Twitter API. Our publications build with v26 era does not appear twitter RSS.

    My doubts are what happens when the upgrade of the viewer of the App.

    If we submit v27 in the app store, v26 publications already downloaded work?.

    The user has already downloaded publications numbers 1 and 2, made with v26. Now release us number 3 built with v27. To download this publication I m assuming he´ll have also update the viewer v27... but won´t need to re - download the publications by v26... Is this true?

    Please tell me the update procedure recommended for Viewer App when West's existing content.

    Thank you

    The upgrade of the application should have no effect on already published folios.

  • problem with update of the number of lines

    Hello..

    Im very new to obiee and now to learn things.

    I'm using the following link to learn how to create a repository and work with it.

    http://www.Oracle.com/technology/OBE/obe_bi/bi_ee_1013/bi_admin/biadmin.html

    and im facing problem by updating the number of lines.

    get a dialog like...

    There was an error while updating the number of lines for "SH"... "" SH ". "" CHANNELS ".
    nQSError:17001Oacle Eroorcode:942, the message: ORA - 00942:table or view does not exist the OIC OCIStmtExecute call: select count (*) channels.
    Failed executing the statement nQSError:17011SQL.

    Wat could be the problem? can anyone help?

    thnx in advance

    Which account you use the update? SH? Check if the account has certain rights that tabel/view.

    concerning

    John
    http://obiee101.blogspot.com

  • problem while updating the number of lines.

    Hello..

    Im very new to obiee and now to learn things.

    I'm using the following link to learn how to create a repository and work with it.

    [http://www.oracle.com/technology/obe/obe_bi/bi_ee_1013/bi_admin/biadmin.html]

    and im facing problem by updating the number of lines.

    get a dialog like...

    There is an error while updating the number of lines for "SH"... "" SH ". "" CHANNELS ".
    + [nQSError:17001] Oacle Eroorcode:942, message: ORA - 00942:table or view does not exist the OIC OCIStmtExecute call: select count (*) channels. +
    + [nQSError:17011] SQL statement execution failed. +

    Wat could be the problem? can anyone help?

    thnx in advance.

    Have you downloaded zip included in the tutorial and placed in the right place?

  • reason for updating a view rather than on the base table

    Can someone tell me what is the reasons that sometimes we would update a view rather than on the base table? I always thought that we cannot update a view, of course, I am wrong. Thank you

    Hi Welcome to the Forum

    Basically, a view is used to present the data, a different way. He can rely on more than one table and we cannot update a
    Discover directly that contains Sql functions, aggregate functions, a group of Clause and a view created excluding the required columns of the table.

    In all the cases mentioned Instead of trigger is very useful

    Published by: user10862473 on July 28, 2009 07:10

Maybe you are looking for