0 Replies Latest reply on Sep 7, 2006 8:06 AM by okep

    Cyclic binding

    okep
      Hello,
      In my scenario I have model class like:
      package cz.deset.admin.flex.model
      {
      [Managed]
      [RemoteClass(alias="cz.deset.admin.flex.model.DataShop")]
      dynamic public class DataShop extends DataBase
      {
      public var label:String = "";
      public var description:String = "";
      public var cannonical:Boolean = false;
      public var springContextConfiguration:String = "";
      public var parsingState:String = "";
      public var createdBy:int = -1;
      public var homepageUri:String = "";

      public function DataShop()
      {
      }
      }
      }

      and MXML component like:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" height="100%"
      label="{_editedShop.label}">
      <mx:Script>
      <![CDATA[
      import mx.rpc.events.ResultEvent;
      import mx.collections.ItemResponder;
      import mx.data.ItemReference;
      import cz.deset.admin.flex.Stores;
      import cz.deset.admin.flex.model.DataShop;

      [Bindable]
      private var _editedShop:DataShop;

      [Bindable]
      private var _editorTabNavigator:EditorTabNavigator;

      public function set editedShop(value:DataShop):void {
      _editedShop = value;
      }

      public function get editedShop():DataShop {
      return _editedShop;
      }

      public function set editorTabNavigator(value:EditorTabNavigator) : void {
      _editorTabNavigator = value;
      }

      public function get editorTabNavigator():EditorTabNavigator {
      return _editorTabNavigator;
      }


      private function save():void {
      Hourglass.show(this);
      var ref:ItemReference = Stores.shopStore.createOrUpdateShop(_editedShop
      , new ItemResponder(
      function (resultEvent:ResultEvent, token:Object=null):void
      {
      var createdShop:DataShop = DataShop(resultEvent.result);
      _editedShop = createdShop;
      Hourglass.remove();
      },
      function (info:Object, token:Object=null):void
      {
      }));

      }

      ]]>
      </mx:Script>


      <mx:Binding source="shopLabel.text" destination="_editedShop.label"/>
      <mx:Binding source="shopDescription.htmlText" destination="_editedShop.description"/>
      <mx:Binding source="shopHomepage.text" destination="_editedShop.homepageUri"/>

      <mx:VBox>
      <mx:ControlBar>
      <mx:Button label="OK" click="save()"/>
      <mx:Button label="Cancel"/>
      <mx:Button label="Revert"/>
      </mx:ControlBar>
      <mx:TabNavigator width="100%" height="100%">
      <mx:Canvas label="Basics" width="100%" height="100%">
      <mx:Form width="100%" height="100%">
      <mx:FormItem label="Label:">
      <mx:TextInput id="shopLabel" width="450" text="{_editedShop.label}"/>
      </mx:FormItem>
      <mx:FormItem label="Description:">
      <mx:RichTextEditor id="shopDescription" width="450" htmlText="{_editedShop.description}"/>
      </mx:FormItem>
      <mx:FormItem label="Homepage:">
      <mx:TextInput id="shopHomepage" width="450" htmlText="{_editedShop.homepageUri}"/>
      </mx:FormItem>
      </mx:Form>
      </mx:Canvas>
      <mx:Canvas label="Branches" width="100%" height="100%">
      </mx:Canvas>
      <mx:Canvas label="Parsing Configuration" width="100%" height="100%">
      </mx:Canvas>
      <mx:Canvas label="Scheduling" width="100%" height="100%">
      </mx:Canvas>
      </mx:TabNavigator>
      </mx:VBox>

      </mx:Canvas>



      Now, when I create new instance of ShopEditor and set editedShop property like this:
      var shopEditor:ShopEditor = new ShopEditor();
      var shop:DataShop = new DataShop();
      shop.label = "some label";
      shopEditor.editedShop = shop;

      all fileds in "shop" are cleared and are empty. When binding from InputTexts to model is removed, "shop" object stays untouched. How to make this cyclic binding behave correctly?

      thx
      Okep