Flex 调用 Action

1.设置数据源(动态传递参数):

<s:HTTPServiceid="httpServiceSend" fault="httpServiceSend_faultHandler(event)" result="httpServiceSend_resultHandler(event)" useProxy="false"> 
      <s:request> 
            <id>{transformationId}</id> 
            <step>{step}</step> 
            <runFlag>{runFlag}</runFlag> 
            <fileName>{fileName}</fileName> 
            <dateFlag>{dateFlag}</dateFlag> 
      </s:request> 
</s:HTTPService>

2.设置出现异常的方法:

protected function httpServiceSend_faultHandler(event:FaultEvent):void
{
      Alert.show(event.fault.messageasString, "提示");
} 

3.设置回调的方法:

protected function httpServiceSend_resultHandler(event:ResultEvent):void
{
      varresult:String = event.resultasString;
      if(result == "SUCCESS"){
            Alert.show( "操作成功!", "提示");
      } else{
            Alert.show("出现错误!", "提示");
      }
} 

4.动态调用数据源提交数据:

private function sendData(event:MouseEvent):void{
      dateFlag = newDate().toString();
      method = "getData";
      httpServiceSend.url = "http://localhost:8080/FlexDataServer/action/data.action";
      httpServiceSend.send();
}

猜你喜欢

转载自blog.csdn.net/kaition/article/details/78819943
今日推荐