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

    Cyclic binding

      In my scenario I have model class like:
      package cz.deset.admin.flex.model
      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%"
      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;

      private var _editedShop:DataShop;

      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 {
      var ref:ItemReference = Stores.shopStore.createOrUpdateShop(_editedShop
      , new ItemResponder(
      function (resultEvent:ResultEvent, token:Object=null):void
      var createdShop:DataShop = DataShop(resultEvent.result);
      _editedShop = createdShop;
      function (info:Object, token:Object=null):void



      <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:Button label="OK" click="save()"/>
      <mx:Button label="Cancel"/>
      <mx:Button label="Revert"/>
      <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 label="Description:">
      <mx:RichTextEditor id="shopDescription" width="450" htmlText="{_editedShop.description}"/>
      <mx:FormItem label="Homepage:">
      <mx:TextInput id="shopHomepage" width="450" htmlText="{_editedShop.homepageUri}"/>
      <mx:Canvas label="Branches" width="100%" height="100%">
      <mx:Canvas label="Parsing Configuration" width="100%" height="100%">
      <mx:Canvas label="Scheduling" width="100%" height="100%">


      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?