• Subscribe  

Flex Mashup III-Salesforce Pipe Map Flickr News

Posted by Moxie Zhang | October 19, 2007 .

After Flex Mashup I and II posts, here is the meat part of it, the code.

There are really two extra Flex APIs to deal with, Map API and Salesforce Flex API. I’ve tried use Adobe RSS Flex parser lib but it kept giving parsing error when parse Pipe’s RSS feed. So gave it up.


I used ESRI’s ArcWeb Service Explorer Flex API. It’s very similar to Yahoo Flex API, which I’ll switch to later to give a try.

So, the application start with:

   1:  <?xml version="1.0" encoding="utf-8"?>
   2:  <mx:Application xmlns:mx="" layout="absolute"
   3:      xmlns:salesforce="com.salesforce.*"
   4:      xmlns:awx=""
   5:      xmlns:style="*"
   6:      width="100%"
   7:      height="100%"
   8:      backgroundColor="#FFFFFF"
   9:      applicationComplete="login();">

The line 3 and 4 above defined the namespaces of the two API.

Showing a map is fairly easy. The code looks like:

   <awx:Map id="map" mapType="streetTiles" borderColor="red" borderThickness="2" scale="50000000" >
       <!-- awx:GeoRSSLayer feedUrl='{DEFAULT_FEED_BURNER}' pollInterval="300" id="dataFeed"/ -->

You’ve noticed I commented out the GeoRSSLayer service provided by AWS API. The reason is that this GeoRSS parser will pass the feed and display the items on the map. That’s it. I have now way to get hold of the data and do something about it. Even Yahoo’s Flex API has the same problem. Real business application mostly is for processing data; data visualization like showing map is helper. So, I have to write the code to pass the GeoRSS feed and put the markers on the map by my code, only because I want to have the handle of the parsed data.

Once issue run into to is how to parse a RSS feed with multiple namespace. Here is the feed segment of the RSS feed look like this:

<?xml version="1.0"?>
<rss version="2.0"



There are three extra namespaces inside the RSS generated by Yahoo Pipe, geo, content and media. The question is how do you use the E4X way to access the data inside the feed. You know, the E4X style is like “”. Here how you would do it:

Namespace geo = resultXML.namespace("geo");

var lat = items[i].geo::lat.toString()

Using the Flex Namespace object with “::” to access the different namespace inside the feed.

Salesforce Flex API

Using Salesforce API is easy too. Add the line: <salesforce:Connection id=”apex”/> will add a salesforce object into you code. The login is like this:

            private function login():void{
                    new LoginRequest
                        {server_url: this.parameters.server_url,
                         session_id: this.parameters.session_id,
                         username: '',
                         password: 'apassword',
                         callback: new AsyncResponder(render)

Of cause I changed my id and password here. Actually the username and password here is only independent salesforce application. Once the application is deployed as module, Salesforce system will pass in the server_url and session_id to allow the application integrate into the session.

As you know, Flex application is an asynchronous system when communicates with server, that’s why you would see salesforce code like this:

        public function renderAcctData():void{
                apex.query("Select Name, BillingPostalCode from Account where BillingPostalCode !=''",
                   new AsyncResponder(
                           function (qr2: QueryResult):void{
                               var ar:ArrayCollection = new ArrayCollection();
                               for (var j:int=0; j<qr2.records.length; j++){
                               var dgColumn:DataGridColumn = new DataGridColumn();
                               dgColumn.headerText = "Name";
                               dgColumn.dataField = "Name";
                               acctGrid.columns = [dgColumn];
                               acctGrid.dataProvider = ar;
                               function (fault:Object):void{}


also noticed is that the you can directly using SQL to access data via its query API.


To deploy the application to, you need to register on appexchange to get Salesforce developer account. The application will be deployed as S-Module, an add-on application for Salesforce. So, what you need are:

  • ArcWeb Servcie Account
  • developer account

I’m changing the map to Yahoo map. The change should be small because the Yahoo Map Flex API is very similar to ArcWeb Service API. Once I got the switch done, I’ll post the code here. You can easily get the Yahoo developer token to play with this application.

That’s it by now.

Leave a Comment

If you would like to make a comment, please fill out the form below.




To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word


To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Related Posts

5 Comments so far
  1. Mansour Raad  October 20, 2007 12:17 pm

    Cool usage of ESRI Flex API.

  2. Kuku  November 5, 2007 4:45 am

    Hi Moxie,

    Do u have a live URL where we could see the final app?


  3. Moxie  November 5, 2007 7:55 pm

    KK, that’ll be hard. The app was deployed to my developer account. Not like web application, there is no link to give out in the hosted env unless I make the application public and you deploy it to your account. That’s why I’m trying to give out the source code. But Yahoo’s map Flex API is still in Flex 1.5. So I can’t change the code now.

  4. Kuku  November 6, 2007 8:21 am

    got it…I guess I will deploy it to my own account. Can u then share the Flex project with the source code?

    thanks so much

  5. Mike  March 11, 2008 5:14 pm

    Trying to do the same. I can’t seem to get ahold of ESRI webservice explorer. Do you know where I can score a eval or have you done this with ArcGIS Online?


Direct TV Offers - usdirect has the best directtv deals