2011-01-19 85 views
0

我使用Flex工作从JVM 1.6 4个调用web服务问题与异步方法

我试图让对Java异步调用来填充3个组合框将显示国家,州和城市,这三者相关(主从关系),但有时呼叫没有被满足,或者他们没有完成,我认为这是因为他们是异步的,我怎么能确定我打电话来填充下一个组合框时,主组合框(国家)填充?

保护的函数comboCountry_changeHandler(idCombo:字符串):无效 {

  selectedComboCountry= idCombo; 
      var countryId:String; 
      if(selectedComboCountry == comboCountry.id){ 
       countryId = String(comboCountry.selectedItem.countryId);     
      }else if(selectedCombocountry == combocountrySuc.id){ 
       countryId = String(comboCountrySuc.selectedItem.countryId); 
      } 



      obtainStatesResult.token = wsfacturas.obtainStates(countryId); 


     } 

保护的函数obtainStatesResult_resultHandler(事件:的ResultEvent):无效 { VAR StateListVo:ArrayCollection的= obtainStatesResult.token.result作为ArrayCollection的;

  if(selectedComboCountry == "comboCountrySuc"){ 

       StateListsSuc.removeAll(); 
       CityListsSuc.removeAll(); 
       for (var d:int = 0; d < StateListVo.length; d++){ 
        var estSuc:State = StateListVo[d]; 
        StateListsSuc.addItem(estSuc);           
       }  

       comboStateSuc.dataProvider = StateListsSuc; 
      } 
      else if(selectedCombocountry == "combocountry"){ 
       StateListsEmp.removeAll(); 
       CityListsEmp.removeAll(); 
       for (var i:int = 0; i < StateListVo.length; i++){ 
        var estEmp:State = StateListVo[i]; 
        StateListsEmp.addItem(estEmp);  
       }     
       comboState.dataProvider = StateListsEmp; 
      } else { 

       for (var f:int = 0; f < StateListVo.length; f++){ 
        var est:State = StateListVo[f]; 
        StateListsSuc.addItem(est); 
        StateListsEmp.addItem(est); 
       }       
       comboState.dataProvider = StateListsEmp; 
       comboStateSuc.dataProvider = StateListsSuc; 

      } 
     } 

回答

1

这难道不是说您可能需要加载国家并等待国家组合框上的更改事件来更新状态等等吗?如果你这样做,你不必担心你的请求的异步性?否则,您可能可以使用DataProviders,他们可能会提供事件:完成..我不确定虽然,我绝对不是专家.. :)

0

您可能想给您的问题稍微详细些。但我只是在玩你提供的任何细节。

1_首先异步调用从来没有给我带来动态数据绑定的问题。有时候,SOAP调用会花费合理的时间,在这种情况下,请确保显示一个忙状态的光标,直到Web服务调用返回。

2_Combobox一直存在动态数据绑定问题。您可以创建自定义组合框来扩展组合框并覆盖setValue方法或者您必须遍历组合框的dataProvider并在数据字段中查找匹配项,然后将组合框设置为该项目。

所以总而言之,问题主要是将新数据绑定到呈现的组合框而非异步调用或任何延迟。

+0

保护的函数comboCountry_changeHandler(idCombo:字符串):无效 \t \t \t \t {\t \t \t \t \t \t \t \t \t \t selectedComboCountry = idCombo; \t \t \t \t var countryId:String; \t \t \t \t如果(selectedComboCountry == comboCountry.id){ \t \t \t \t \t countryId =字符串(comboCountry.selectedItem.countryId); \t \t \t \t \t \t \t \t}否则,如果(selectedCombocountry == combocountrySuc。id){ \t \t \t \t \t countryId = String(comboCountrySuc.selectedItem.countryId); \t \t \t \t} \t \t \t \t \t \t \t \t \t \t \t \t \t \t obtainStatesResult.token = wsfacturas.obtainStates(countryId); \t \t \t \t \t \t \t \t \t \t \t \t} – overmann 2011-01-19 02:37:42