Skip to Content

Flash Islands: strange behaviour using a ArrayCollection / data binding

Hi all,

I'm making my first steps in Flash Islands and as an real-life example, I tried to display a ABAP table in a DataGrid. I know about the principle "don't solve problems with Islands which could be solved with WD", bit it was just for learning. After this example would work, I'm striving for refactoring it to a more complex graphical solution as in the tutorials.

<p>I encountered a problem while trying to use an ArrayCollection and display it in a DataGrid. A typically Flex code snippet would be like this:

	<mx:Script>
		<![CDATA[
	import mx.collections.ArrayCollection;
	[Bindable]
	public var myData : ArrayCollection
	// fill the myData collection here
		
	
	
 
 
		
  
  
			
   
   
			
   
   
			
   
   
		
  
  
	
 
 
]]>

This coding didn't work - I thought about a WDA configuration mapping problem.

After a time-consuming examination I found, that the following coding works:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
	width="100%" height="100%"
	preinitialize="preInit()"
	initialize="initApp()"
	>
	<mx:Script>
		<![CDATA[
			import mx.collections.ArrayCollection;
			import sap.FlashIsland;
	 		[Bindable]
	 		public var col1 : String
	 		[Bindable]
	 		public var col2 : String
	 		[Bindable]
	 		public var col3 : String
	 		[Bindable]
			public var myData : ArrayCollection
			private function preInit() : void {
				myData = new ArrayCollection()
			}
			private function initApp() : void {
				FlashIsland.register(this)
			}
		
	
	
 
 
		
  
  
			
   
   
			
   
   
			
   
   
		
  
  
	
 
 

]]>

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Jul 15, 2009 at 11:39 AM

    Second Part

    (The second part is necessary due to length limitation, see [Forum Limitation Notifcation|formatting-of-sdn-forum-replies])

    Note the curly braces use in the dataField property and the additional public variables col1, col2, col3. None of these additions are necessary in standard Flex code!

    So my question is: is this the standard way of working with an ArrayCollection? Or did I get something wrong?

    Thanks in advance,

    Christian.

    PS: Is there a forum dedicated specially to Flash Islands?

    Add comment
    10|10000 characters needed characters exceeded

    • This is because the columns of the array collection are built dynamically off of the attributes of bound context node within Web Dynpro. The usage of string variables like col1, col2, etc are aliases for the actual column names. You bind the mapping within Web Dynpro of these column name alias variables to the actual attributes. At runtime they get filled with the context attribute names. You have to use the formatting becuase you starting to Flex to use the value in this variable as the actual column name. This gives you the freedom to change the names of the attributes on the WD side without having to change any coding on the Flex side. Give it a try.

      And no there isn't really a forum dedicated to FlashIslands. We do have an RIA forum where purely Flex questions get asked sometimes. Although for topics related to the Islands framework, it is probably better to put them with the Web Dynpro Forum.

  • Jul 15, 2009 at 01:09 PM

    Thanks Thomas for the clarification.

    I understand your explanation, but I'm wondering whether I'll have to introduce lots of public variables if using larger array collections.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      I used a similar code in Flex to get array collection values from ABAP wd and display in my Flex datagrid, but it is not working. My datagrid is not displaying any values. Below is the code which I am using,

      <?xml version="1.0" encoding="utf-8"?>

      http://www.adobe.com/2006/mxml" layout="vertical" width="100%" height="100%" preinitialize="preInit()" initialize="initApp()">

      <mx:Script>

      <![CDATA[

      import mx.collections.ArrayCollection;

      import sap.FlashIsland;

      [Bindable]public var ekkoDS:ArrayCollection;

      [Bindable]public var EBELN:String;

      [Bindable]public var BSART:String;

      [Bindable]public var EKORG:String;

      [Bindable]public var EKGRP:String;

      [Bindable]public var ERNAM:String;

      [Bindable]public var AEDAT:String;

      [Bindable]public var BUKRS:String;

      private function preInit():void{

      ekkoDS = new ArrayCollection();

      }

      private function initApp():void{

      FlashIsland.register(this);

      }

      ]]>

      </mx:Script>

      <mx:DataGrid id="dg" dataProvider="">

      <mx:columns>

      <mx:DataGridColumn id="col1" dataField="" headerText="EBELN"/>

      <mx:DataGridColumn id="col2" dataField="" headerText="BSART"/>

      <mx:DataGridColumn id="col3" dataField="" headerText="EKORG"/>

      <mx:DataGridColumn id="col4" dataField="" headerText="EKGRP"/>

      <mx:DataGridColumn id="col5" dataField="" headerText="ERNAM"/>

      <mx:DataGridColumn id="col6" dataField="" headerText="AEDAT"/>

      <mx:DataGridColumn id="col7" dataField="" headerText="BUKRS"/>

      </mx:columns>

      </mx:DataGrid>

      </mx:Application>

      Can anyone let me know where I am going wrong?

      Thanks!