呼叫响应者的异步调用
我的 Flex
应用程序有问题。正如您在下面的代码示例中看到的,我尝试向 vgroup 添加一些面板。这些面板从我的 MYSQL 数据库获取标题。我的问题是我无法等待 callresponder
的异步调用,因此面板没有被填充。如何等待DB的数据?
如果我尝试构建一个带有按钮的新面板,它就可以工作。当我按下按钮时,会出现一个带有正确标题的面板。
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600"
xmlns:produktservice="services.produktservice.*"
xmlns:valueObjects="valueObjects.*">
<fx:Script>
<![CDATA[
import mx.containers.Panel;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
private var zaehler:int = 0;
private function getProduktByID(i:int):void
{
getProduktByIDResult.token = produktService.getProduktByID(i);
}
private function init():void
{
for(var i:int=0; i<10; i++)
{
getProduktByID(818+i);
}
}
protected function getProduktByIDResult_resultHandler(event:ResultEvent):void
{
var dynamicPanel:Panel;
dynamicPanel = new Panel();
dynamicPanel.id="dynamicPanel"+zaehler;
dynamicPanel.width=400;
dynamicPanel.height=200;
dynamicPanel.title=getProduktByIDResult.lastResult.titel;
vPanelGroup.addElement(dynamicPanel);
}
protected function button1_clickHandler(event:MouseEvent):void
{
getProduktByID(818+zaehler);
zaehler++;
}
]]>
</fx:Script>
<fx:Declarations>
<produktservice:ProduktService id="produktService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
<s:CallResponder id="getProduktByIDResult" result="getProduktByIDResult_resultHandler(event)"/>
<valueObjects:Produkt id="produkt"/>
<!-- Platzieren Sie nichtvisuelle Elemente (z. B. Dienste, Wertobjekte) hier -->
</fx:Declarations>
<s:VGroup id="vPanelGroup" gap="10" creationComplete="init()">
</s:VGroup>
<s:Button x="726" y="270" label="Button" click="button1_clickHandler(event)"/>
</s:Application>
I have a problem with my Flex
-Application. As you can see in the code-sample below i try to add some panels to a vgroup. The panels are getting their title from my MYSQL
db. My problem is that I can't wait on the async call of the callresponder
, so the panel doesn't get filled. How can I wait for the data from DB?
If i try to build a new panel with a button it works. When i press the button one panel appears with the right title.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600"
xmlns:produktservice="services.produktservice.*"
xmlns:valueObjects="valueObjects.*">
<fx:Script>
<![CDATA[
import mx.containers.Panel;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
private var zaehler:int = 0;
private function getProduktByID(i:int):void
{
getProduktByIDResult.token = produktService.getProduktByID(i);
}
private function init():void
{
for(var i:int=0; i<10; i++)
{
getProduktByID(818+i);
}
}
protected function getProduktByIDResult_resultHandler(event:ResultEvent):void
{
var dynamicPanel:Panel;
dynamicPanel = new Panel();
dynamicPanel.id="dynamicPanel"+zaehler;
dynamicPanel.width=400;
dynamicPanel.height=200;
dynamicPanel.title=getProduktByIDResult.lastResult.titel;
vPanelGroup.addElement(dynamicPanel);
}
protected function button1_clickHandler(event:MouseEvent):void
{
getProduktByID(818+zaehler);
zaehler++;
}
]]>
</fx:Script>
<fx:Declarations>
<produktservice:ProduktService id="produktService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
<s:CallResponder id="getProduktByIDResult" result="getProduktByIDResult_resultHandler(event)"/>
<valueObjects:Produkt id="produkt"/>
<!-- Platzieren Sie nichtvisuelle Elemente (z. B. Dienste, Wertobjekte) hier -->
</fx:Declarations>
<s:VGroup id="vPanelGroup" gap="10" creationComplete="init()">
</s:VGroup>
<s:Button x="726" y="270" label="Button" click="button1_clickHandler(event)"/>
</s:Application>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是吗
?
Is it
?