[flexcoders] Hold execution untill result from database
Hi all (again... I'm having a productive day ;) ) I'm trying to lift the creation of components to a new level (at least, for me) What I have: (if it is possible...) 1. I have an .AS-class which describes a person. To keep it simple, the person only has a name(String) and a photo(String - the URI). 2. A/ I have a databasetable with the following structure ObjectClass | propertyName | renderType B/ Another database table as follows renderType | bindPropertyName 3. I have an AS-class(UICF) in my own lib, having following method public static getUIComponent(object:Object, objectClass:Class, propertyName:String, propertyType:Class):UIComponent 4. I have a canvas What should happen: In the creationComplete of the canvas(4) a new Person is created: var p:Person = new Person("Foo", "images/bar.jpg"); Now the canvas(4) calls the getUIComponent(3) for rendering the image: var c:UIComponent = UICF.getUIComponent(p, Person, "photo", String); The method(3) returns the correct component, being an imagecomponent and the canvas(4) just adds it to it's children: this.addChild(c); The problem is inside getUIComponent(3). This method should do a call to my database to find out which type of component it should create and which property to set. For this example, the db would look like this: First Table ObjectClass | propertyName | renderType Personphoto Image Second Table renderType | bindPropertyName Image source However, if I recall correctly, all database requests made by Flex are Asynchronous. One option I see, is to have a boolean which gets sets by a resulthandler, and create a lock-up-loop in getUIComponent. However there might just be another (better?) way, to wait for my response and then create and return the correct component. Thanks in advance, --Johan
RE: [flexcoders] Hold execution untill result from database
I assume you're talking AIR rather than true Flex, right? Synchronous database queries were added in beta 2. Michael Krotscheck Senior Developer RESOURCE INTERACTIVE <http://www.resource.com/> www.resource.com <http://www.resource.com> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> This email and any of its attachments may contain Resource Interactive proprietary information, which is privileged, confidential and may be subject to copyright or other intellectual property rights belonging to Resource Interactive. This email is intended solely for the use of the individual or entity to which it is addressed. If you are not the intended recipient of this email, you are hereby notified that any dissemination, distribution, copying or action taken in relation to the contents of and attachments to this email is strictly prohibited and may be unlawful. If you have received this email in error, please notify the sender immediately and permanently delete the original and any copy of this email and any printout. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of johantrax Sent: Wednesday, October 31, 2007 12:25 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Hold execution untill result from database Hi all (again... I'm having a productive day ;) ) I'm trying to lift the creation of components to a new level (at least, for me) What I have: (if it is possible...) 1. I have an .AS-class which describes a person. To keep it simple, the person only has a name(String) and a photo(String - the URI). 2. A/ I have a databasetable with the following structure ObjectClass | propertyName | renderType B/ Another database table as follows renderType | bindPropertyName 3. I have an AS-class(UICF) in my own lib, having following method public static getUIComponent(object:Object, objectClass:Class, propertyName:String, propertyType:Class):UIComponent 4. I have a canvas What should happen: In the creationComplete of the canvas(4) a new Person is created: var p:Person = new Person("Foo", "images/bar.jpg"); Now the canvas(4) calls the getUIComponent(3) for rendering the image: var c:UIComponent = UICF.getUIComponent(p, Person, "photo", String); The method(3) returns the correct component, being an imagecomponent and the canvas(4) just adds it to it's children: this.addChild(c); The problem is inside getUIComponent(3). This method should do a call to my database to find out which type of component it should create and which property to set. For this example, the db would look like this: First Table ObjectClass | propertyName | renderType Person photo Image Second Table renderType | bindPropertyName Image source However, if I recall correctly, all database requests made by Flex are Asynchronous. One option I see, is to have a boolean which gets sets by a resulthandler, and create a lock-up-loop in getUIComponent. However there might just be another (better?) way, to wait for my response and then create and return the correct component. Thanks in advance, --Johan
RE: [flexcoders] Hold execution untill result from database
Perhaps set creationPolicy="none", then trigger a call to createChildren() from the resultHandler. Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of johantrax Sent: Wednesday, October 31, 2007 12:25 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Hold execution untill result from database Hi all (again... I'm having a productive day ;) ) I'm trying to lift the creation of components to a new level (at least, for me) What I have: (if it is possible...) 1. I have an .AS-class which describes a person. To keep it simple, the person only has a name(String) and a photo(String - the URI). 2. A/ I have a databasetable with the following structure ObjectClass | propertyName | renderType B/ Another database table as follows renderType | bindPropertyName 3. I have an AS-class(UICF) in my own lib, having following method public static getUIComponent(object:Object, objectClass:Class, propertyName:String, propertyType:Class):UIComponent 4. I have a canvas What should happen: In the creationComplete of the canvas(4) a new Person is created: var p:Person = new Person("Foo", "images/bar.jpg"); Now the canvas(4) calls the getUIComponent(3) for rendering the image: var c:UIComponent = UICF.getUIComponent(p, Person, "photo", String); The method(3) returns the correct component, being an imagecomponent and the canvas(4) just adds it to it's children: this.addChild(c); The problem is inside getUIComponent(3). This method should do a call to my database to find out which type of component it should create and which property to set. For this example, the db would look like this: First Table ObjectClass | propertyName | renderType Person photo Image Second Table renderType | bindPropertyName Image source However, if I recall correctly, all database requests made by Flex are Asynchronous. One option I see, is to have a boolean which gets sets by a resulthandler, and create a lock-up-loop in getUIComponent. However there might just be another (better?) way, to wait for my response and then create and return the correct component. Thanks in advance, --Johan
Re: [flexcoders] Hold execution untill result from database
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 - Original Message - From: "johantrax" <[EMAIL PROTECTED]> To: Sent: Wednesday, October 31, 2007 4:25 PM Subject: [flexcoders] Hold execution untill result from database > Hi all (again... I'm having a productive day ;) ) > > I'm trying to lift the creation of components to a new level (at > least, for me) > What I have: (if it is possible...) > 1. > I have an .AS-class which describes a person. To keep it simple, the > person only has a name(String) and a photo(String - the URI). > 2. > A/ I have a databasetable with the following structure >ObjectClass | propertyName | renderType > B/ Another database table as follows >renderType | bindPropertyName > 3. > I have an AS-class(UICF) in my own lib, having following method >public static getUIComponent(object:Object, objectClass:Class, > propertyName:String, propertyType:Class):UIComponent > 4. > I have a canvas > > What should happen: > In the creationComplete of the canvas(4) a new Person is created: >var p:Person = new Person("Foo", "images/bar.jpg"); > Now the canvas(4) calls the getUIComponent(3) for rendering the image: >var c:UIComponent = UICF.getUIComponent(p, Person, "photo", > String); > The method(3) returns the correct component, being an imagecomponent > and the canvas(4) just adds it to it's children: >this.addChild(c); > > The problem is inside getUIComponent(3). This method should do a call > to my database to find out which type of component it should create > and which property to set. For this example, the db would look like this: >First Table >ObjectClass | propertyName | renderType > Personphoto Image >Second Table >renderType | bindPropertyName > Image source > > However, if I recall correctly, all database requests made by Flex are > Asynchronous. One option I see, is to have a boolean which gets sets > by a resulthandler, and create a lock-up-loop in getUIComponent. > However there might just be another (better?) way, to wait for my > response and then create and return the correct component. > > Thanks in advance, > --Johan > > > > -- > 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 > > > >