如何从后端显示成功消息并在flex前端显示?

时间:2011-04-20 10:54:26

标签: flex backend

在将记录插入后端后,如何在前端显示成功消息。 我正在使用FLEX作为前端而Toad作为后端。

2 个答案:

答案 0 :(得分:2)

假设前端使用RemoteObject,WebService或HTTPService进行远程调用,那么当您从服务器获得成功结果时,每个远程调用都会调度结果事件。我会使用结果处理程序来显示警报。

答案 1 :(得分:0)

在mxml中使用remoteObject

<mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;

            private function resultHandler(event:ResultEvent):void
            {
                Alert.show("Back with success");
                Alert.show(event.message.toString());
            }

            private function faultHandler(event:FaultEvent):void
            {
                Alert.show("Back with Error");
                Alert.show(event.message.toString());
            }

        ]]>
    </mx:Script>
    <mx:RemoteObject id="remoteObject" destination="yourdestination"
                            showBusyCursor="true"
                            result="{resultHandler(event)}"
                            fault="{faultHandler( event )}">
    </mx:RemoteObject>

注意:上面的代码在Flex3中

希望有所帮助