Thanks, that is exactly what I was looking for. Zdenek M
--- In [email protected], Jeff Vroom <[EMAIL PROTECTED]> wrote: > > We've been wanting to add a "prefetchAndExecute" type of utility which would make this a little easier. I think what you are doing is good though it would be a bit more efficient to just call: > > arrayCollection.getItemAt(0, arrayCollection.length) > > That second parameter is the "prefetch" parameter which specifies the number of items to fetch. That one call with thrown an IPE if all items are not resident. > > The advantage of doing this all at once is that we can make one big request to the server instead of fetching each page independently. > > Jeff > > From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of zdenekmikan > Sent: Monday, August 11, 2008 2:08 AM > To: [email protected] > Subject: [flexcoders] Re: LCDS: how to fetch the items from lazy collection > > > 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]<mailto:flexcoders%40yahoogroups.com>, "marcel.panse" <marcel.panse@> > 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]<mailto:flexcoders%40yahoogroups.com>, "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]<mailto:flexcoders%40yahoogroups.com>, 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 > > > > > > > > > >

