2 Replies Latest reply on Sep 8, 2008 7:05 PM by barg27

    ModelLocator Binding Not Writing

    barg27
      I am switching my AIR application over to Cairngorm and I'm having a terrible time with binding to my ModelLocator. It reads nested value object properties, but it won't write to them and I can't figure out why. There are no warnings indicating Binding won't be available. Once I update a text field, the value remains the same. Here's some code:
        • 1. Re: ModelLocator Binding Not Writing
          Level 7
          Bindings re one way by default. There's lots about this in the Help, and
          you might find this useful:

          http://link.brightcove.com/services/player/bcpid1733261879?bclid=1729365228&bctid=17412126 60

          "barg27" <webforumsuser@macromedia.com> wrote in message
          news:ga4j66$dme$1@forums.macromedia.com...
          >I am switching my AIR application over to Cairngorm and I'm having a
          >terrible
          > time with binding to my ModelLocator. It reads nested value object
          > properties,
          > but it won't write to them and I can't figure out why. There are no
          > warnings
          > indicating Binding won't be available. Once I update a text field, the
          > value
          > remains the same. Here's some code:
          >
          > /* ModelLocator */
          >
          > [Bindable]
          > public class ModelLocator {
          > private static var _instance:ModelLocator = null;
          >
          > private var _currentUser:User = new User();
          >
          > public static function getInstance():ModelLocator {
          > if (!_instance)
          > _instance = new ModelLocator();
          >
          > return _instance;
          > }
          >
          >
          > public function get currentUser():User {
          > return _currentUser;
          > }
          >
          > public function set currentUser(user:User):void {
          > _currentUser = user;
          > }
          > }
          >
          > /* User Value Object */
          >
          > public class User {
          > private var _id:String = "";
          > private var _firstName:String = "";
          >
          > [Bindable]
          > public function get id():String {
          > return _id;
          > }
          >
          > public function set id(id:String):void {
          > _id = id;
          > }
          >
          >
          > [Bindable]
          > public function get firstName():String {
          > return _firstName;
          > }
          >
          > public function set firstName(name:String):void {
          > _firstName = name;
          > }
          > }
          >
          > <!-- MXML -->
          >
          > <![CDATA[
          > [Bindable]
          > private var _model:ModelLocator = ModelLocator.getInstance();
          > ]]>
          >
          > <mx:TextInput y="110" horizontalCenter="32" id="firstNameField"
          > tabIndex="0"
          > text="{_model.currentUser.firstName}"
          > toolTip="{resourceManager.getString('CreateUserForm',
          > 'firstNameTooltip')}"
          > />
          >


          • 2. Re: ModelLocator Binding Not Writing
            barg27 Level 1
            Wow. Yes, that makes sense. I originally treated my forms as one-way binding before the switch to Cairngorm. I don't know why my thought pattern changed.

            Thanks.