4 Replies Latest reply on Sep 20, 2006 5:28 PM by Dr._Goomba

    Problem populating tabnavigator with returned data

    Dr._Goomba Level 1
      I am trying to populate a tabnavigator with data. I am experiencing that only the first tab displays data, but each subsequent tab does not. It seems as though when you click another tab it looses the "key" value passed. Whats the reason for this and how can i attach the "key" value to all tabs?

      Thanks!


      Heres my code:

      <?xml version="1.0" encoding="utf-8"?>
      <cfComponents:SizeableTitleWindow xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*"
      xmlns:cfComponents="com.adobe.ColdFusion.components.*"
      xmlns:cfDataGrid="com.adobe.ColdFusion.components.datagrid.*"
      xmlns:model="com.cfgenerated.models.*"
      xmlns:view="com.cfgenerated.views.detail.movie.*"
      creationComplete="initComponent()"
      explicitMaxHeight="{Application.application.height - 50}"
      title="Details"
      showCloseButton="true"
      close="WindowManager.remove(this);">


      <mx:Metadata>
      [Event("change")]
      </mx:Metadata>

      <mx:Script>
      <![CDATA[
      import mx.utils.ObjectUtil;
      import mx.controls.Alert;
      import mx.core.Application;
      import mx.validators.Validator;
      import com.adobe.windowedApplication.managers.WindowManager;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.events.FaultEvent;
      import com.cfgenerated.models.*;

      private var _key:Object;

      public function get key():Object {
      return this._key;
      }

      public function set key(key:Object):void {
      this._key = key;
      getItem();
      }

      private function initComponent():void {
      this.detailObject = new MovieDetailstblMovies();
      }

      /*
      Remote Server Calls and Call back handlers
      */
      // get an instance of the item from the server
      public function getItem():void {
      if( this._key != null ) {
      this.dataManager.getById(this._key);
      }
      else {
      // the key is null, so we'll create a new object for the 'add' operation.
      this.detailObject = new MovieDetailstblMovies();
      }
      }

      private function saveItem(item:Object):void {
      this.dataManager.save(item);
      }

      private function get_result(event:ResultEvent):void {
      var detail:MovieDetailstblMovies = event.result as MovieDetailstblMovies;
      this.detailObject = detail;
      }

      ]]>
      </mx:Script>

      <mx:RemoteObject id="dataManager" showBusyCursor="true" destination="ColdFusion"
      source="myTest.components.cfgenerated.MovieDetails.tblMoviesGateway">
      <mx:method name="getById" result="get_result(event)"/>
      </mx:RemoteObject>

      <!-- create a model, using the AS Value Object class. With this mxml version of the model we can bind the form fields back to the object. -->
      <model:MovieDetailstblMovies id="detailObject">
      <model:title>{tblMovies_title.text as String}</model:title>
      <model:description>{tblMovies_description.text as String}</model:description>
      <model:features>{tblMovies_features.text as String}</model:features>
      </model:MovieDetailstblMovies>

      <mx:TabNavigator width="675" height="408">
      <mx:Canvas label="Tab1" width="100%" height="100%">
      <mx:Label text="Title" x="10" y="10"/>
      <cfComponents:TextInputMask id="tblMovies_title" text="{this.detailObject.title}" width="220" y="36" x="10"/>
      </mx:Canvas>
      <mx:Canvas label="Tab2" width="100%" height="100%">
      <cfComponents:TextInputMask id="tblMovies_description" text="{this.detailObject.description}" width="351" height="138" x="10" y="36"/>
      <mx:Label x="10" y="10" text="Description"/>
      </mx:Canvas>
      <mx:Canvas label="Tab3" width="100%" height="100%">
      <mx:Label text="Extra Features" x="10" y="10"/>
      <cfComponents:TextInputMask id="tblMovies_features" text="{this.detailObject.features}" width="291" height="218" x="10" y="36"/>
      </mx:Canvas>
      </mx:TabNavigator>

      </cfComponents:SizeableTitleWindow>