cancel
Showing results for 
Search instead for 
Did you mean: 

Flash Island: ArrayCollection returns always null

Former Member
0 Kudos

Hi @all,

on WD-site I created a DataSource with several attrbutes, which I binded to the context. The context will be filled at runtime.

In Flex I did the ArrayCollection and attributes bindable with the same name, I used in WD.

For testing, I always use in Flex the DataGrid-Component to be sure, that the swf-file receives the data.

So far, all is good and the DataGrid receives the data - perfect.

But now, I want to select values of the ArrayCollection.

Normally I do it with standard-method of Flex(getItemAt(index).attribute)

My code snippet is:

[Bindable]
public var dataSource:ArrayCollection = new ArrayCollection();
[Bindable]
public var Name:String;
[Bindable]
public var Street:String;
[Bindable]
public var Country:String;

for(var i:int = 0; i < dataSpurce.length; i++)
{
     Alert.show(dataSource.getItemAt(i).Name + " " + dataSource.getItemAt(i).Street + " " + dataSource.getItemAt(i).Country);
    //Alert.show(dataSource<i>.Name + " " + dataSource<i>.Street + " " + dataSource<i>.Country);
}

The return values are always "null null null", although the DataGrid receives the correct values.

What is wrong in this syntax?

Thanks for your help,

Dirk

Edited by: D.Sorgatz on Feb 19, 2010 5:34 PM

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

That is becuase the bindable variables that you created for the attributes of the DataSource aren't necessarily the names of the items in your Array Collection.

So lets say that your context in WD has attributes of the node named name1, street1, country1 - but you bind those to DataSource Properties name, street, country. The resulting Array Collection in Flex will be generated with the items named name1, street1, country1 - not name, street, country. The Array Collection takes on whatever the names of the bound context attributes were on the WD side.

The other bound variables are just strings that hold the Web Dynpro Context Attribute names. They can be used to dynamically reference the Array Collection items without having to know the actual WD Context Attribute names. They also allow the WD Context Attribute names to change over time without breaking your Flex code.

For example:

row = dataSource.getItemAt(i);
alert.show(row[Street]);

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Thomas,

thank you for your solution.

Best regards,

Dirk

Former Member
0 Kudos

May be replace dataSpurce.length with dataSource.length. Typo error ?