I'm new to flex and I can't seem to get this to work. Essentially, I have a select box with which it's available data is dependent on another combo box.
There are multiple TreatmentTypes in each CategoryType.
Here's my code:
Combo box change; update select box:
private function refreshAvailableTreatmentTypes():void {
// this is the combo box
fAccomplishment.habitatType = habitatTypeId.selectedIndex != -1 ? habitatTypeId.selectedItem as HabitatType : null;
// fAccompRemote is a RemoteObject
var treatmentList:ArrayCollection = fAccompRemote.getValidTreatments(fAccompForm.accomplishment, fAccomplishment.habitatType);
if ( fAccompForm.categoryTypes != null ) {
// All categories are always shown. These are passed to the form on construction.
for each ( var currentCat:CategoryType in fAccompForm.categoryTypes ) {
var catAdded:Boolean = false;
/* loop through all the treatments in each Category and add them to
* the available list if they meet the criteria */
for each ( var currentTreat:TreatmentType in currentCat.treatments ) {
if (currentTreat.id in treatmentList || treatmentList.length == 0) {
if (!catAdded) {
// fCatsAndTreats defined as a [Bindable] private var
fCatsAndTreats.addItem( currentCat );
catAdded = true;
}
fCatsAndTreats.addItem( currentTreat );
}
}
}
}
}
Service Method:
@RemotingInclude
public List<TreatmentType> getValidTreatments(Accomplishment accomp, HabitatType selectedHabitatType){
if ( accomp == null || accomp.getGeometry() == null || accomp.getHabitatType() == null) {
return new ArrayList<TreatmentType>();
}
Geometry accompGeo = accomp.getGeometry();
List<TreatmentType> optionList = new ArrayList<TreatmentType>();
String geomName = null;
if ( accompGeo instanceof Point || accompGeo instanceof MultiPoint ) {
geomName = "Point";
} else if ( accompGeo instanceof LineString || accompGeo instanceof MultiLineString) {
geomName = "Line";
} else if ( accompGeo instanceof Polygon || accompGeo instanceof MultiPolygon ) {
geomName = "Polygon";
}
Integer habTypeId = null;
if (selectedHabitatType == null) {
habTypeId = accomp.getHabitatType().getId();
} else {
habTypeId = selectedHabitatType.getId();
}
optionList = accomplishmentDao.getValidTreatments(geomName, habTypeId);
return optionList;
}
TypeError: Error #1034: Type Coercion failed: cannot convert mx.rpc::AsyncToken@1af48641 to mx.collections.ArrayCollection.
How do I do this? I found THIS but it doesn't seem to help me quite so much: . Any resources or information would be greatly appreciated.