Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Populate data grid

Avatar

Level 1
hi i need to populate the data grid in mxml.

For that i need to call jsp from flex to get data.
2 Replies

Avatar

Level 2
Hi,



There is an easy to read document at
http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_2.html,
and even though it is about PHP, you could use the url as JSP.



HTH.



Alice

Avatar

Level 4
This code may help once you get your data back. It accesses a
data file but many of the principles are the same.



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

<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"

creationComplete="dataRequest.send()">

<mx:Script>

<![CDATA[

import mx.events.ListEvent;

import mx.collections.XMLListCollection;

import mx.rpc.events.ResultEvent;



[Bindable] private var dataxlc:XMLListCollection = new
XMLListCollection();



private function resultHandler(e:ResultEvent):void {

var xmllist:XMLList = new XMLList(e.result..product);

dataxlc = new XMLListCollection(xmllist);

}

]]>

</mx:Script>

<mx:HTTPService id="dataRequest" useProxy="false"
resultFormat="e4x"

result="resultHandler(event)" url="data3.xml"/>

<mx:DataGrid dataProvider="{dataxlc}"
rowCount="{dataxlc.length}">

<mx:columns>

<mx:DataGridColumn dataField="@partnum"

headerText="Part Number"/>

<mx:DataGridColumn dataField="name"

headerText="Product Name"/>

</mx:columns>

</mx:DataGrid>

</mx:Application>

------------------------------- data3.xml
-----------------------------------

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

<products>

<product partnum="001">

<name>Desk</name>

</product>

<product partnum="002">

<name>Chair</name>

</product>

<product partnum="003">

<name>Table</name>

</product>

<product partnum="004">

<name>Bookshelf</name>

</product>

<product partnum="005">

<name>Lamp</name>

</product>

<product partnum="006">

<name>Computer</name>

</product>

<product partnum="007">

<name>Monitor</name>

</product>

</products>