[flex] felx+lcds+hibernate
feng03628
2008-11-07
刚学flex,遇到一个问题,就是数据库中的数据体现不到界面。哪位给看这里的问题,就是想在comboBox里出来数据库里的数据。
把server端的方法写在了hibernateSessionFactory中 public Collection findAllClasses(){ Session session = getSessionFactory().openSession(); Query q = session.createQuery("from Classes"); return q.list(); } remoting-config.xml中的 <destination id="ClassManager"> <properties> <source>com.hibernate.util.HibernateSessionFactory</source> </properties> </destination> 然后我写的MXML如下: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()"> <mx:Script> <![CDATA[ import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import mx.rpc.remoting.RemoteObject; import mx.collections.ArrayCollection; import mx.controls.Alert; [Bindable] private var array:ArrayCollection = new ArrayCollection(); private function init():void{ var classDAO:RemoteObject = new RemoteObject("ClassManager"); classDAO.addEventListener(FaultEvent.FAULT,findFault); classDAO.addEventListener(ResultEvent.RESULT,findResult); classDAO.findAllClasses(); } private function findFault(event:FaultEvent):void{ Alert.show(event.message.toString(),"调用失败"); } private function findResult(event:ResultEvent):void{ array = ArrayCollection(event.result); cmb.dataProvider = array; } ]]> </mx:Script> <mx:ComboBox x="225" y="125" id="cmb" dataProvider="{array}"></mx:ComboBox> </mx:Application> 最后run on server就是显示“调用失败”。到底是为什么啊?? |