Charlie, I wasn't aware of the itemClass property (not a database or sql guy) and I think you may be right that that is what I need to use, but I might have to change how I am storing the Product object...
Currently, since the user can configure multiple products I add the configured
Product object to an array
private function addCurrentToMaster():void{
quoteMaster[0] = cartDP;
if ( quoteMaster.length == 0 ){
quoteMaster[1] = addProduct;
} else {
quoteMaster[cartDP.length] = addProduct;
}
// Clear Previous Product
productOptionsVS.removeAllChildren();
} // END addCurrentToMaster()
Then I clear out my viewStack and wait for the user to select another product
to configure with options. (You will note that I use the first slot in the
array to hold my dataGrid dataProvider.)
When I write the object (which is actually an array with several Product
Objects in it) to my database, it is sent along with other data:
private function saveRecord( name:String ):void{
// ADD EVENT LISTENER
sqlQuoteConnection.addEventListener(
SimpleSQLConnectionEvent.ITEM_ADDED, addRecordComplete );
// EXECUTE SQL ACTION
sqlQuoteConnection.create( quoteName, quoteMaster, getDate() );
} // END saveRecord()
When I read the data back into my app I call my SimpleSQLConnection class
(quotedata is the array of Products),
public function readOpenQuotes(event:SimpleSQLConnectionEvent = null):void {
// This sql command retrieves OPEN quotes from our Table in the
database and orders it by DATE
var sqlStatement:String = "SELECT id, status, date, name,
quotedata " +
"FROM productQuote
WHERE status='1'
ORDER BY date DESC";
// Add EVENT LISTENER
sqlQuoteConnection.addEventListener(SimpleSQLConnectionEvent.READ_COMPLETE,
parentDocument.openQuoteReadComplete);
// EXECUTE SQL ACTION
sqlQuoteConnection.read(sqlStatement);
trace("GET OPEN");
} // END readOpenQuotes()
The read() function in my SimpleSQLConnection class is where I assume the
itemClass would be added
private function select(stmt:String):void{
var selectStatement:SQLStatement = new SQLStatement();
selectStatement.text = stmt;
selectStatement.sqlConnection = sqlConnection;
selectStatement.addEventListener(SQLEvent.RESULT, onSelect);
selectStatement.addEventListener(SQLErrorEvent.ERROR, errorHandler);
selectStatement.text = stmt;
selectStatement.execute();
} // END select()
However since the results data is not a Product, rather the quotedata is part
that contains the array containing the products selected, I am not sure how to
identify the quotedata as the itemClass. I am afraid that I may have to go back
to the example I got the SimpleSQLConnection class from and rework my class...
in the example (now that I am looking back on it) they created a ItemTO class
and typed all the data being added to the database with that class and then
used the itemClass in their call for data.
I will see if I can rework it and get it on the right track... thanks so much
you heading me in the right direction.
Mike
-----Original Message-----
From: [email protected] on behalf of Charlie Hubbard
Sent: Wed 8/19/2009 11:41 AM
To: [email protected]
Subject: Re: [AFFUG Discuss] Saving and retrieving objects in AIr
It just sounds like you have a bug in the layer that saves your object to
the database. How are you saving and retrieving the object? What does your
DAO look like? SQL?
Rereading your post I think maybe you have a class called Product and you're
wanting to get back a Product object from sql when you query the database.
You need to set the itemClass in order to get AIR to instantiate your
specific object. Otherwise it just comes back as a plain Object in which
case you'd get a NULL when casting to your user defined Product type.
Still seeing your code (simplified) could help.
Charlie
On Wed, Aug 19, 2009 at 11:32 AM, Hepp, Michael W.
<[email protected]>wrote:
> Greetings All,
>
> I am wondering if it is possible to save generated Objects and then
> retrieve them in the state they were saved in... e.g. I have a product quote
> generator app created in AIR. Based on the product the user selects a number
> of options on seperate pages with radio buttons are created and added to a
> ViewStack via my AddProduct() class and the user goes through and selects
> the various options he wants for that particular product. This configuration
> can then be saved to a pdf and a local SQLite database.
>
> I am writing the AddProduct() object directly to the database, but when I
> retrieve it, is comes back in a slightly different form... an Object with
> two properties and when I try to type it to an AddProduct() I get a null
> value.
>
> I don't know if I am explaining this well enough, but any input/ideas on
> how to get this data back in the same form as the Object was save would be
> greatly appreciated.
>
> Mike
>
> -------------------------------------------------------------
> To unsubscribe from this list, simply email the list with unsubscribe in
> the subject line
>
> For more info, see http://www.affug.com
> Archive @ http://www.mail-archive.com/discussion%40affug.com/
> List hosted by FusionLink <http://www.fusionlink.com>
> -------------------------------------------------------------
-------------------------------------------------------------
To unsubscribe from this list, simply email the list with unsubscribe in the
subject line
For more info, see http://www.affug.com
Archive @ http://www.mail-archive.com/discussion%40affug.com/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------
<<winmail.dat>>
