J'ai un problème avec mon projet où j'essaie de remplir une liste avec mes données XML que je sors d'un fichier php. J'appelle le fichier php avec un httpservice et ce fichier renvoie des données XML. Maintenant, il semble qu'il y ait un problème, mais je ne reçois aucune erreur. Je sais juste après le débogage que mon XMLListCollection reste null.httpService et XMLListCollection
Voici mon code:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:components="components.*"
creationComplete="httpService.send()">
<s:layout>
<s:VerticalLayout paddingTop="20" gap="20"
horizontalAlign="center" />
</s:layout>
<fx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
import mx.collections.XMLListCollection;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
private var alert:Alert;
private function httpService_fault(evt:FaultEvent):void {
var title:String = evt.type + " (" + evt.fault.faultCode + ")";
var text:String = evt.fault.faultString;
alert = Alert.show(text, title);
Bezoekers.removeAll();
}
private function httpService_result(evt:ResultEvent):void {
var xmlList:XMLList = XML(evt.result).bezoekers.bezoeker;
Bezoekers = new XMLListCollection(xmlList);
}
]]>
</fx:Script>
<fx:Declarations>
<s:HTTPService id="httpService"
url="http://localhost/projectnieuw/src/data/bezoekersList.php"
resultFormat="e4x"
fault="httpService_fault(event);"
result="httpService_result(event)" />
<!--<fx:Model id="lijstAlleLeden" source="httpAlleLeden" />-->
<!--<s:ArrayCollection id="acBezoekers" source="{Bezoekers}"/>-->
<s:XMLListCollection id="Bezoekers"/>
</fx:Declarations>
<components:Heading/>
<s:HGroup gap="50">
<components:BezoekersList bezoekerList="{Bezoekers}" />
<components:ReservationForm/>
</s:HGroup>
</s:Application>
Je ne semble pas obtenir ce qui ne va pas.
Merci à l'avance
Salutations de Belgique
J'ai déjà testé l'url de mon HttpService dans le navigateur et renvoie les données XML. J'ai changé le resultFormat en xml mais Bezoekers reste null. Je vais lire la documentation maintenant. – user1941525