Archive for April, 2010

Basic git commands

April 17, 2010

>> download to local

git clone {git:/ /url.git}

>>syn with repository at server (like “update” at svn)

cd [to local working copy]

git fetch

>> configure proxy

git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

Binding XML as dataProvider in Flex 4

April 10, 2010

Problem: You want to bind an XMLList object (such as the results you get from a static or dynamically generated XML file) as the data source for some views (called data provider components) in your UI. You assign the XMLList to the dataProvider property like this:

<s:DataGroup dataProvider="{menuLoader.lastResult.step[0].item}"
itemRenderer="components.MMChoicesItemRenderer">...</s:DataGroup>

<s:HTTPService id="menuLoader"
resultFormat="e4x"
url="mymenu.xml"
fault="onMenuHTTPFault(event)"
result="onMenuHTTPResult(event);"/>

But you get a runtime TypeError,  something like:

TypeError: Error #1034: Type Coercion failed: cannot convert XMLList@284a62a9 to mx.collections.IList.

Reason:

Despite the fact that it’s named “List”, XMLList turned out to be a top level Flash object that doesn’t implement the mx.collection.IList interface, which is required for a data source to be qualified as a DataProvider. The commonly used classes that implement IList are ArrayCollection, ArrayList (curiously) and XMLListCollection.

Solution:

The TypeError happens when you tried to set the resultFormat of your HTTPService to “e4x” and bind it directly to the dataProvider property of some components.

Option 1 is to wrap the XMLList into an XMLListCollection before using it as a dataProvider. Like so:

<s:DataGroup dataProvider="{new XMLListCollection(XMLList(menuLoader.lastResult.step[0].item))}" >...</s:DataGroup>

Option 2 is to not use “e4x” as the resultFormat, instead use the default “object” as the resultFormat, then you are free to bind the result directly as dataProvier:

<s:DataGroup dataProvider="{menuLoader.lastResult.steps.step[0].item}" >...</s:DataGroup>

Notice that when the resultFormat is not set to e4x, the HTTPService.lastResult is not the top XML object any longer and you need to drill down one more level to get the XML object.

Also an example from Flex Examples.