0 Replies Latest reply on Aug 5, 2011 12:18 AM by isabelle loyer

    Simultaneous httpservice in the same component

    isabelle loyer

      Dear Flexer,

      I created an Air application.
      On loading my component, I'd to make simultaneous request to my database to load some data to my component.

      My component is a form with several comobobox and and text field.

      But to do that I have two major problem.
      - Sometimes, my form (my component) is loaded but there no information  in my text field, perhaps request is not finished? but how to verify  that and how to solve.
      - Other question, as requests with http service is for different table,  one to load sudent, other to load note, other to load teaching , is it  possible to do this request in the same php file and to get all thos  informations with the same E4X file.

      Thanks for help

       

      [Code]

       

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

      <windowSkin:NativeTitleWindow 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:windowSkin="fr.intersystemes.ui.windowSkin.*"

        xmlns:skins="fr.intersystemes.ui.skins.*"

        xmlns:tabBarClasses="flexlib.controls.tabBarClasses.*"

        minWidth="800" minHeight="800" borderVisible="false"

        creationComplete="onLoad(event)"

        currentState="tb1"

        dropShadowVisible="false"

        skinClass="fr.intersystemes.ui.windowSkin.NativeTitleWinSkin">

      <windowSkin:states>

      <s:State name="tb1"/>

      <s:State name="tb2"/>

      <s:State name="tb3"/>

      <s:State name="tb4"/>

      <s:State name="tb5"/>

      <s:State name="tb6"/>

       

       

      </windowSkin:states>

       

       

       

       

      <fx:Declarations>

      <!-- Placer ici les éléments non visuels (services et objets de valeur, par exemple). -->

      <s:HTTPService id="phpPatientDetail"

         showBusyCursor="true"

         useProxy="false"

         resultFormat="e4x"

         method="POST"

         result="detailPatient(event)"

         fault="trace(this + event.fault.toString());">

       

      </s:HTTPService>

       

      <s:HTTPService id="phpLoadTypeDossier"

         showBusyCursor="true"

         useProxy="false"

         resultFormat="e4x"

         method="POST"

         result="allDossier(event)"

         fault="trace(this + event.fault.toString());">

       

      </s:HTTPService>

       

      <s:RadioButtonGroup id="rbsex"/>

       

       

      </fx:Declarations>

       

      <fx:Metadata>

      [Event(name="myEventClose", type="fr.intersystemes.ui.windowSkin")]

      </fx:Metadata>

       

      <fx:Script>

      <![CDATA[

      import fr.intersystemes.VO.PatientVO;

      import fr.intersystemes.config.urlManager;

      import fr.intersystemes.util.DateUtility;

      import fr.intersystemes.util.FileSerializer;

      import fr.intersystemes.util.UserPrefs;

       

      import mx.collections.ArrayCollection;

      import mx.events.FlexEvent;

      import mx.events.IndexChangedEvent;

      import mx.events.ItemClickEvent;

      import mx.rpc.events.ResultEvent;

       

      import spark.events.IndexChangeEvent;

      [Bindable]

      public var monIdPatient:String;

       

      private var pg:UserPrefs;

      [Bindable]

      public var PAT_TB_ARRAY:ArrayCollection = new ArrayCollection (

      [{label:"Personnelles"},

      {label:"Assuré & Sécu. Soc"},

      {label:"Compléments perso"},

      {label:"Autres adresses"},

      {label:"Cursus"},

      {label:"Archives"}]

      );

       

       

      [Bindable]

      private var DP_PAT_CIVIL:ArrayCollection = new ArrayCollection (

      [{label:"Monsieur"},

      {label:"Madame"},

      {label:"Mademoiselle"},

      {label:"Le Jeune"}]

       

      );

       

      [Bindable]

      private var DP_PAT_ADRDEF:ArrayCollection = new ArrayCollection (

      [{label:"Monsieur"},

      {label:"Madame"},

      {label:"Mademoiselle"},

      {label:"Le Jeune"}

      ]

      );

       

      [Bindable]

      private var DP_PAT_DOS1:ArrayCollection = new ArrayCollection (

      [{label:"N° Etudiant"},

      {label:"N° INEE"},

      {label:"Liberer"}

      ]);

       

      [Bindable]

      private var DP_PAT_DOS2:ArrayCollection = new ArrayCollection (

      [{label:"N° Etudiant"},

      {label:"N° INEE"},

      {label:"Liberer"}

      );

       

      [Bindable]

      private var DP_PAT_TEL:ArrayCollection = new ArrayCollection (

      [{label:"Maison"},

      {label:"Bureau"},

      {label:"Pére"},

      {label:"Mére"}]

       

      );

      protected function onLoad(event:FlexEvent):void

      {

      this.pg = FileSerializer.readObjectFromFile("prefSaisiePat.up") as UserPrefs;

       

       

       

      var urlPatient:urlManager = new urlManager();

      phpPatientDetail.url=urlPatient.urlService() + "loadStudentById.php";

       

      var paramsPatient:Object = new Object();

      paramsPatient.idPatient = monIdPatient;

       

      phpPatientDetail.send(paramsPatient);

      phpLoadTypeDossier.send();

       

      }

       

      private function onMyEventClose(e:Event):void

      {

       

       

       

       

      }

       

      private function allDossier(event:ResultEvent)

      {

       

      }

      private var objectPatient:PatientVO;

       

      private function detailPatient(event:ResultEvent):void

      {

       

      trace(this + event.result.toString());

       

      var resultXml:XML = event.result as XML;

      // -- --

      var aNode:XML;

      var list:Array = new Array();

      // -- --

      // we use resultXml.children() (and not resultXml..customer)

       

      var dateConv : DateUtility = new DateUtility();

       

      trace ("result" + resultXml.children().length());

      for each (aNode in resultXml.children())

      {

      objectPatient = new PatientVO();

      // -- --

      objectPatient.paIndex = Number(aNode.@id);

      objectPatient.paNomP = aNode.@np ;

      objectPatient.paPrenom = aNode.@pr ;

      objectPatient.paCodePostal = aNode.@cp;

      objectPatient.paDossier1 = aNode.@d1;

      objectPatient.paDossier2 = aNode.@d2;

      objectPatient.paNaissance = dateConv.dateStringToObject(aNode.@dn);

      objectPatient.paNumTel1 = aNode.@tel;

       

      }

       

       

      lNom.text = objectPatient.paNomP;

       

      lPrenom.text = objectPatient.paPrenom;

      //lAge.text = dateConv.calculAgeAn(objectPatient.paNaissance) as String;

      lAge.text = " - " + dateConv.calculAgeAn(objectPatient.paNaissance) + " ans et " + dateConv.calculAgeMois(objectPatient.paNaissance) + " mois";

      lNaissance.text = "Né(e) le " + dateConv.dateToStringFR(objectPatient.paNaissance);

      this.title = objectPatient.paNomP + " "+ objectPatient.paPrenom;

      fdNom.text = objectPatient.paNomP;

      dfNaissance.text = dateConv.dateToStringFR(objectPatient.paNaissance);

      }

      private function reloadPatient():void{

       

      }

      private function tbClickEvt(evt:IndexChangeEvent):void {

      // Access target TabBar control.

       

      //var targetComp:TabBar = TabBar(evt.currentTarget);

       

      switch(evt.target)

      {

      case 0:

      {

      currentState="tb1";

      break;

      }

       

      case 1:

      {

      currentState="tb2";

      break;

      }

      case 2:

      {

      currentState="tb3";

      break;

      }

       

      case 3:

      {

      currentState="tb4";

      break;

      }

       

      case 4:

      {

      currentState="tb5";

      break;

      }

       

      case 5:

      {

      currentState="tb6";

      break;

      }

      default:

      {

      currentState="tb1";

      break;

      }

      }

       

       

       

      }

       

       

       

      ]]>

      </fx:Script>

       

       

       

      <s:Group width="100%" height="100%">

      <s:layout>

      <s:BasicLayout/>

       

      </s:layout>

       

      <s:Image x="0" y="0" width="53" height="53" click="reloadPatient()"/>

      <s:VGroup x="100" y="8" width="100%" gap="5" verticalAlign="top"> <!-- Groupe central-->

       

      <s:HGroup> <!-- Nom prenom-->

      <s:Label text="Nom" id="lNom" fontWeight="bold"/>

      <s:Label text="Prénom" id="lPrenom" fontWeight="bold"/>

      </s:HGroup>

       

      <s:HGroup width="100%"> <!-- Naissance-->

      <s:Label text="Naissance" id="lNaissance" />

      <s:Label text=" / Age" id="lAge"/>

      </s:HGroup>

      </s:VGroup >

       

      <s:VGroup x="730" y="0" horizontalAlign="right" verticalAlign="top" paddingLeft="5"> <!-- Modif-->

      <s:Label text="Crea" id="lCrea"/>

      <s:Label text="Modif" id="lModif"/>

      </s:VGroup>

       

      <!-- Partie avec onglet-->

       

       

       

      <s:ButtonBar x="0" y="74" dataProvider="{PAT_TB_ARRAY}" change="tbClickEvt(event);"/>

       

       

      <s:Form x="0" y="94" id="foPerso" width="100%" height="100%" includeInLayout="true" includeIn="tb1">

       

      <s:layout>

      <s:FormLayout gap="3" paddingLeft="0"/>

       

      </s:layout>

       

       

       

      <s:HGroup width="100%" gap="3" horizontalAlign="left" resizeMode="noScale"

        verticalAlign="baseline" >

       

       

      <s:DropDownList id="cbQualite" dataProvider="{DP_PAT_CIVIL}"/>

      <s:FormItem label="Nom" >

      <s:TextInput id="fdNom" width="200" focusColor="#D55E5E" focusEnabled="true"

      tabIndex="1" text="Mon nom"/>

      </s:FormItem>

      <s:FormItem  label="Prénom" >

      <s:TextInput id="fdPrenom" width="200" tabIndex="2"/>

      </s:FormItem>

      <s:DropDownList id="cbDossier1" dataProvider="{DP_PAT_DOS1}" width="118" height="22" tabIndex="3"/>

      <s:FormItem label="" >

      <s:TextInput id="fDossier1" width="90" paddingRight="5" tabIndex="4"/>

      </s:FormItem>

      </s:HGroup>

       

       

      <s:Group>

      <s:FormItem label="Naissance" tabIndex="5" >

      <mx:DateField id="dfNaissance" width="100" editable="true" formatString="DD/MM/YYYY" yearNavigationEnabled="true"/>

      </s:FormItem>

      <s:RadioButton x="90" y="0" label="Masculin" group="{rbsex}" tabIndex="6"/>

      <s:RadioButton x="170" y="0" label="Féminin" group="{rbsex}" tabIndex="7"/>

      <s:DropDownList id="cbDossier2" x="340" y="0" width="118" height="22"

      dataProvider="{DP_PAT_DOS1}" tabIndex="8"/>

      <s:FormItem x="460" y="0" label="" tabIndex="9">

      <s:TextInput id="fDossier2" width="90" paddingRight="5"/>

      </s:FormItem>

      </s:Group>

       

      <s:HGroup width="100%" horizontalAlign="left" resizeMode="noScale" verticalAlign="baseline">

      <s:FormItem label="Qualité" tabIndex="10">

      <s:DropDownList id="cbQualiteParent" width="130"/>

      </s:FormItem>

       

      <s:FormItem label="Nom" tabIndex="11">

      <s:TextInput id="tiNomPar" width="200" text="NomParent"/>

      </s:FormItem>

       

      <s:FormItem label="Prénom" tabIndex="12">

      <s:helpContent>

      <s:VGroup>

      <s:Label text="Prénom du responsable" />

      </s:VGroup>

      </s:helpContent>

      <s:TextInput id="tiPrenomPAr" width="200"/>

      </s:FormItem>

      </s:HGroup>

       

       

      <s:HGroup width="100%" horizontalAlign="left" resizeMode="noScale" verticalAlign="baseline">

      <s:FormItem label="Adresse par défaut"  tabIndex="12" >

      <s:DropDownList id="cbAdrDef" dataProvider="{DP_PAT_ADRDEF}"/>

      </s:FormItem>

       

      <s:FormItem label="Adresse" tabIndex="13">

       

      <s:TextInput id="tiAdr1" width="480" text="Adr"/>

      <s:TextInput id="tiAdr2" width="480"/>

      </s:FormItem>

      </s:HGroup>

       

      <s:HGroup width="100%" horizontalAlign="left" resizeMode="noScale" verticalAlign="baseline">

      <s:FormItem label="Code Postal" tabIndex="14">

      <s:TextInput id="tiCP" text="CP" width="65"/>

      </s:FormItem>

       

      <s:FormItem label="Ville" tabIndex="15">

      <s:TextInput id="tiVille" text="Ville" width="250"/>

      </s:FormItem>

       

      <s:FormItem label="Pays" tabIndex="16">

      <s:TextInput id="tiPays" text="Pays" width="175"/>

      </s:FormItem>

       

      </s:HGroup >

       

      <s:HGroup height="20" horizontalAlign="left" resizeMode="noScale" verticalAlign="baseline" paddingTop="5">

      <s:Label text="Téléphones"/>

      <s:Spacer width="39" height="20"/>

      <s:Label text="SMS"/>

      </s:HGroup>

       

      <s:HGroup width="100%" horizontalAlign="left" resizeMode="noScale" verticalAlign="baseline">

      <s:DropDownList id="paTabTel1" dataProvider="{DP_PAT_TEL}" tabIndex="17"/>

      <s:CheckBox id="cbSMS1" selected="true" tabIndex="18"/>

      <s:TextInput id="paTel1" width="120" text="Tel1" tabIndex="19"/>

      <s:TextInput id="paRemTel1" width="480" text="RemTel1" tabIndex="20"/>

      </s:HGroup>

       

      <s:HGroup width="100%" horizontalAlign="left" resizeMode="noScale" verticalAlign="baseline">

      <s:DropDownList id="paTabTel2" dataProvider="{DP_PAT_TEL}" tabIndex="21"/>

      <s:CheckBox id="cbSMS2" selected="true" tabIndex="22"/>

      <s:TextInput id="paTel2" width="120" text="Tel2" tabIndex="23"/>

      <s:TextInput id="paRemTel2" width="480" text="RemTel2" tabIndex="24"/>

      </s:HGroup>

       

      <s:HGroup width="100%" horizontalAlign="left" resizeMode="noScale" verticalAlign="baseline">

      <s:DropDownList id="paTabTel3" dataProvider="{DP_PAT_TEL}" tabIndex="25"/>

      <s:CheckBox id="cbSMS3" selected="true" tabIndex="26"/>

      <s:TextInput id="paTel3" width="120" text="Tel3" tabIndex="27"/>

      <s:TextInput id="paRemTel3" width="480" text="RemTel3" tabIndex="28"/>

      </s:HGroup>

      <s:HGroup width="100%" horizontalAlign="left" resizeMode="noScale" verticalAlign="baseline">

      <s:FormItem label="Télécopie">

      <s:TextInput id="paFax" width="120" text="Fax" tabIndex="29"/>

      </s:FormItem>

      <s:FormItem label="Email">

      <s:TextInput id="paMail" width="333" text="Mail" tabIndex="30"/>

      </s:FormItem>

      </s:HGroup>

      <s:HGroup width="100%" horizontalAlign="left" resizeMode="noScale" verticalAlign="baseline">

      <s:FormItem label="Prof. des parents">

      <s:TextInput id="paProfPar" width="180" text="Prof Par" tabIndex="31"/>

      </s:FormItem>

      <s:FormItem label="du père">

      <s:TextInput id="paProfPere" width="180" text="du père" tabIndex="32"/>

      </s:FormItem>

      <s:FormItem label="de la mère">

      <s:TextInput id="paProfMere" width="180" text="de la mère" tabIndex="33"/>

      </s:FormItem>

       

      </s:HGroup>

       

      <s:Line width="100%" height="3"/>

      <s:HGroup width="100%" horizontalAlign="left" resizeMode="noScale" verticalAlign="baseline">

      <s:FormItem label="Rub1" >

      <s:layout>

      <s:HorizontalLayout/>

      </s:layout>

      <s:TextInput id="paUserR1" width="220" text="Rub1" tabIndex="34"/>

      <s:CheckBox id="cbRB1" tabIndex="35"/>

      </s:FormItem>

      <s:FormItem label="Rub5">

      <s:layout>

      <s:HorizontalLayout/>

      </s:layout>

      <s:TextInput id="paUserR5" width="220" text="Rub5" tabIndex="36"/>

      <s:CheckBox id="cbRB5" tabIndex="37"/>

      </s:FormItem>

      </s:HGroup>

       

      <s:HGroup width="100%" horizontalAlign="left" resizeMode="noScale" verticalAlign="baseline">

      <s:FormItem label="Rub2">

      <s:layout>

      <s:HorizontalLayout/>

      </s:layout>

      <s:TextInput id="paUserR2" width="220" text="Rub2" tabIndex="37"/>

      <s:CheckBox id="cbRB2" tabIndex="38"/>

      </s:FormItem>

      <s:FormItem label="Rub6">

      <s:layout>

      <s:HorizontalLayout/>

      </s:layout>

      <s:TextInput id="paUserR6"  width="220" text="Rub6" tabIndex="39"/>

      <s:CheckBox id="cbRB6" tabIndex="40"/>

      </s:FormItem>

      </s:HGroup>

       

      <s:HGroup width="100%" horizontalAlign="left" resizeMode="noScale" verticalAlign="baseline">

      <s:FormItem label="Rub3">

      <s:layout>

      <s:HorizontalLayout/>

      </s:layout>

      <s:TextInput id="paUserR3"  width="220" text="Rub3" tabIndex="41"/>

      <s:CheckBox id="cbRB3" tabIndex="42"/>

      </s:FormItem>

      <s:FormItem label="Rub7">

      <s:layout>

      <s:HorizontalLayout/>

      </s:layout>

      <s:TextInput id="paUserR7"  width="220" text="Rub7" tabIndex="43"/>

      <s:CheckBox id="cbRB7" tabIndex="44"/>

      </s:FormItem>

      </s:HGroup>

       

      <s:HGroup width="100%" horizontalAlign="left" resizeMode="noScale" verticalAlign="baseline">

      <s:FormItem label="Rub4">

      <s:layout>

      <s:HorizontalLayout/>

      </s:layout>

      <s:TextInput id="paUserR4"  width="220" text="Rub4" tabIndex="45"/>

      <s:CheckBox id="cbRB4" tabIndex="46"/>

      </s:FormItem>

      <s:FormItem label="Rub8">

      <s:layout>

      <s:HorizontalLayout/>

      </s:layout>

      <s:TextInput id="paUserR8"  width="220" text="Rub8" tabIndex="47"/>

      <s:CheckBox id="cbRB8" tabIndex="48"/>

      </s:FormItem>

      </s:HGroup>

       

      </s:Form>

       

      </s:Group>

       

      </windowSkin:NativeTitleWindow>

      [/Code]