Reputation: 2077
I want to retrieve data from a Database and display inside a datagrid in a Flex web application. The way I'm thinking of doing it is :
I know what to use but I have an ambiguity. In the (.mxml) I use xxx.send() to send the data. What do I use in the (.jsp) to send it back ?
Also, I know that I should store the results in an XML in the .jsp file, but how to do that ?
Upvotes: 0
Views: 710
Reputation: 2881
You just output the XML data directly to the screen as you would with any other jsp web page. Pretend you're making a jsp to display some html, same concept applies, just display the XML instead.
yourpage.jsp :
<% java.util.Date date = new java.util.Date(); %>
<root><time><%= date %></time></root>
When you receive it, it will be stuffed into the result event based on the result format. For XML like you're talking, you'll want your service to look something like :
<mx:HTTPService id="myService" url="yourpage.jsp" method="GET"
resultFormat="e4x" result="myServiceResponse(event)" fault="httpFaultHandler(event)" showBusyCursor="true"/>
Then your response method looks something like this :
private function settingsResponse( e : ResultEvent) : void {
myXML = e.result as XML;
mx.controls.Alert.show('current server date/time is ' + String(myXML.time) );
// ...do whatever you want with your xml now!...
}
Upvotes: 1