Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Retrieving XML from Java Component

Avatar

Level 2
Does anyone have a walkthrough or anything that kinda shows
this process? I know I am doing something wrong, but I am not sure
what. I think its just a syntax error like I am doing things in the
wrong order or missing some step.



Here is my java code: (I know tomcat is connecting to it, and
I know flex is also because the logger shows me the return
information)



package javaSamples;



// Simple class to pass an xml message

public class DataGrid

{

public String getDataGrid()

{

String xml = "";

xml +="<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +

"<grid>" +

"<items>" +


"<item><name=\"Book\"><price=\"10.99\"></item>"
+


"<item><name=\"Lamp\"><price=\"49.00\"></item>"
+


"<item><name=\"Chair\"><price=\"99.99\"></item>"
+

"</items>" +

"</grid>";



return xml;

}

}





Here is my MXL file.



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

<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="{dataGridObject.getDataGrid()}">

<mx:RemoteObject id="dataGridObject"
destination="dataGrid">

<mx:method name="getDataGrid" concurrency="last"
result="setDataGrid(event.result as XML)"/>

</mx:RemoteObject>

<mx:Script>

<![CDATA[



import mx.rpc.events.ResultEvent









private function setDataGrid(a:XML):void{



var newXML:XML = a;

//trace(myDP.item[0].name);

}

[Bindable] var myDP:XML = newXML;



]]>

</mx:Script>

<mx:Panel x="10" y="232" width="250" height="200"
layout="absolute" title="Simple Data Grid">

<mx:DataGrid x="0" y="10" width="230"
dataProvider="{dataGridObject.getDataGrid}">

<mx:columns>

<mx:DataGridColumn headerText="Name"
dataField="name"/>

<mx:DataGridColumn headerText="Price"
dataField="price"/>

<mx:DataGridColumn headerText="Column 3"
dataField="col3"/>

</mx:columns>

</mx:DataGrid>

</mx:Panel>



</mx:Application>





If anyone has an example of this I would really appreciate
any help.
0 Replies