----- Original Message ----- From: "johantrax" <[EMAIL PROTECTED]> To: <flexcoders@yahoogroups.com> Sent: Thursday, November 01, 2007 11:03 AM Subject: [flexcoders] Re: Hold execution untill result from database
>I think this is rather what I was doing, > > The canvas raises the creationComplete-event and contains info about > what children should be instantiated. > Then this canvas requests that instance by calling getUIComponent(). > This static method is part of a class called UIComponentFactory, a > part of my lib. > It is UIComponentFactory that connects to a Java-service (I'm thinking > RPC would be fit here) and the Java-class that connects with the db, > and sends the result back to UICF.getUIComponent(). At that moment, > the method instantiates the component and returns it to it's caller > (in this case the canvas). > > However, if I have a slow db, my user will see a canvas with some > hardcoded parts on, that then gradually updates itself to it's final > form (as the resulthandlers are getting invoked). Instead of not > seeing anything, and then a complete canvas... If I understand this correctly you are already building that interface before you go and get the data - the canvas is there then tries to add children but can't because of the DB delay. You could build your interface with placeholders that are filled in as the data is retrieved. For example, if you had a form component that was going to show fields from the database - instantiate the form as a blank form, then either the form component picks up a custom event 'formDataReadyEv' generated by the DB handler and uses the event payload to populate the form, or the DB handler will update the model and you have the form bound to the model. So, the whole thing goes like this: Instantiate Canvas. Instantiate Form (blank) Initiate DB transfer DB data received Update Model and/or raise custom event Form updates (either through binding or by handling the custom event). So the interface builds quickly, but populates itself at the speed of the DB connection. Paul > --Johan > > --- In flexcoders@yahoogroups.com, "Paul Andrews" <[EMAIL PROTECTED]> wrote: >> >> I'm not sure having a visual component doing database calls is a good >> architecture, though I haven't really gone through your code. >> >> In an MVC architecture the UI should raise an event. The model should >> recognise the event, initiate the DB transfer, on transfer complete > you can >> raise another event to alert the GUI to update itself or just bind > to the >> model. >> >> I suspect that in your case, the canvas should not be responding to > creation >> complete by trying to initiate the creation of the person for > display. On >> creation complete, you should ask the model to fetch a person. The > model >> should then initiate the DB transfer and handle the asynchronous > completion >> event. On completion, it can either update part of the model with > the person >> data (and use binding from the GUI to update the display), or raise > an event >> to alert the GUI to update itself and create the visual for the person. >> >> Paul > > > > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com > Yahoo! Groups Links > > > >