Modification d'une combobox à partir d'un controller.
Bonjour
Débutante en flex je rencontre quelques soucis, en effet, je suis face à une interface créer par mes soins suite à une phase de login. Il y a 3 combobox. Selon l'utilisateur je souhaite updater les combobox.
J'appelle donc un WebService pour me fournir ces informations, jusque là pas de soucis, j'ai les bonnes.
En revanche, je n'arrive pas à updater ma combobox avec ces données.
Je souhaite initialiser ma combobox lors de la création de la vue, c'est pour cela qu'elle se trouve dans le constructeur du modele.
Voici mon code
Celui de la vue :
Code:
1 2
|
<ns1:TbsComboBox x="10" y="3" width="100" id="titleList" /> |
celui de mon modele
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
package fr.trias.flex.projects.xrail.models
{
import com.tbsfrance.fwk.flex.patterns.mvc.mvcClasses.ModelHelper;
import flash.events.IEventDispatcher;
import fr.trias.flex.projects.xrail.Other.Globals;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.soap.WebService;
import mx.rpc.soap.LoadEvent;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.controls.TileList;
[Bindable]
public class CheminFerMH extends ModelHelper
{
private var _WSListeTitle:WebService;
private var _WSListeTitleLoaded:Boolean;
private var _id:String;
public function CheminFerMH(target:IEventDispatcher=null)
{
super(target);
loadTitleList();
}
public function initWebService():void
{
_WSListeTitleLoaded = false;
_WSListeTitle = new WebService();
_WSListeTitle.useProxy = false;
_WSListeTitle.wsdl = getFlashVarsValue("WSDL");
_WSListeTitle.addEventListener(LoadEvent.LOAD, onWSDLLoad);
_WSListeTitle.addEventListener(ResultEvent.RESULT, getListeTitleResult);
_WSListeTitle.addEventListener(FaultEvent.FAULT, getListeTitleFailed);
}
public function getListeTitleResult(e:ResultEvent):void {
var result : ArrayCollection = e.result as ArrayCollection;
var str : String;
setControllerOperation("cheminFerAssemblage","loadTitleList",result);
}
public function getListeTitleFailed(e:FaultEvent):void {
}
public function onWSDLLoad(event:LoadEvent):void {
_WSListeTitleLoaded = true;
}
public function loadTitleList():void {
var id:String;
_id = LoginMH._id;
//id = LoginMH.getId();
Alert.show(_id,"Recup Global");
var idint:int;
idint = parseInt(_id);
//Alert.show(idint.toString());
initWebService();
if(!_WSListeTitleLoaded) // On s'assure que la WSDL est chargée avant d'appeler le webservice
{
// on charge la WSDL
_WSListeTitle.loadWSDL();
// on appelle le webService
_WSListeTitle.endpointURI = getFlashVarsValue("WS_ENDPOINT");
_WSListeTitle.WS_ListeTitresProd(idint);
}
else
{
// on appelle le webService
_WSListeTitle.endpointURI = getFlashVarsValue("WS_ENDPOINT");
// nom du webservice dans la base 4D
_WSListeTitle.WS_ListeTitresProd(idint);
}
}
}
} |
et finalement celui de mon controleur
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
public function loadTitleList(result:ArrayCollection):void
{
Alert.show("Controller");
var maCombo:ComboBox = controller.getView("CheminFerView", "cheminFerAssemblage").titleList;
Alert.show("tableau color array initialisation");
var COLOR_ARRAY:Array=
[{label:"Red", data:"#FF0000"},
{label:"Green", data:"#00FF00"},
{label:"Blue", data:"#0000FF"}];
Alert.show("ArrayList color AC initialisation");
var colorAC:ArrayCollection;
colorAC = new ArrayCollection(COLOR_ARRAY);
Alert.show(COLOR_ARRAY.length.toString(),"Taille du tableau couleur");
maCombo.dataProvider(colorAC);
var args :Array = [result[0].length]
maCombo.initialize();
maCombo.dataProvider(colorAC);
/*
var myDP: Array;
myDP = [
{Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99},
{Artist:'Pavarotti', Album:'Twilight', Price:11.99},
{Artist:'Other', Album:'Other', Price:5.99}];
maCombo.dataProvider = myDP; */
//maCombo.se
//setModelOperation(
}
}
} |
au niveau controler, l'exécution s'arrête lorsque j'essaye de récupéré ma comboBox