In fact I do not have any backend code in my project - I use the Hibernate Assembler from LCDS to supply data (DTOs) into my flex client. My lazy ArrayCollection is partly fetched from the server - just the items needed for display. Now when I want to export all items into file, I need to fetch all the remaining items into this collection. So I am looking for some simpler solution to do this.
Zdenek M --- In [email protected], "marcel.panse" <[EMAIL PROTECTED]> wrote: > > This is a backend problem not a flex problem. Your java backend > application fetches the data lazily from the database, which means he > doesn't fetch it at all until you need it at runtime. When you send > this lazily loaded object through LCDS over the line to your flex > application it loses the ability to runtime fetch the lazy collection > from the database (because you are already on the client machine, not > on the server anymore, not in session). > > Just make sure whatever you send through LCDS over the wire is not > lazily loaded. So load all collection explicitly with hibernate before > you send them. Or better yet don't send hibernate objects of the wire > at all, create DTO (Data Transfer Objects; search for DTO design > pattern) objects instead. Load everything you need in your flex > application into the DTO and send that over to your flex app. > > gr > marcel > > > > --- In [email protected], "zdenekmikan" <zdenek@> wrote: > > > > I was able to solve my problem with following async loop, but I > wonder if there is some > > simpler solution. > > > > private var itemArray:ArrayCollection > > private var index:int; > > private var count:int; > > private var noIPE:Boolean; > > > > public function execute(cgEvent:CairngormEvent):void > > { > > count = itemArray.length; > > index = 0; > > noIPE = true; > > > > start(); > > } > > > > private function start():void > > { > > try > > { > > trace("start: " + index); > > while((noIPE == true) && (index < count)) > > { > > processItem(null, itemArray.getItemAt(index) as > > ItemDTO); > > } > > } > > catch(ipe:ItemPendingError) > > { > > noIPE = false; > > trace("item pending error: " + index); > > ipe.addResponder(new ItemResponder(processItem, fetchError)); > > } > > } > > > > private function fetchError(message:ErrorMessage):void > > { > > trace("error fetching item: " + message.faultString); > > } > > > > private function processItem(data:Object, item:ItemDTO = null):void > > { > > trace("processItem: " + index); > > if(item == null) > > item = itemArray.getItemAt(index) as ItemDTO; > > > > ..... > > > > index++; > > if(index < count) > > { > > if(noIPE == false) > > { > > noIPE = true; > > start(); > > } > > } > > else > > { > > finish(); > > } > > } > > > > > > --- In [email protected], Zdenek Mikan <zdenek@> wrote: > > > > > > I have an ArrayCollection which is filled from the LCDS/Hibernate > > > destination with lazy=true. For display it is OK, but for export I > need > > > to go through all items to send them to output. Is there any way > how to > > > force fetch all items from the server? > > > > > > BTW the sample in LCDS ES 2.6 Developer Guide on page 242-243 is > wrong - > > > you will get the ipe exception on line with ipe.addResponder in catch > > > clause. > > > > > > Zdenek M > > > > > >

