Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 10-29-2006, 05:59 PM   #1
CDHBookingEdge
Registered User
 
Join Date: Oct 2006
Posts: 383
Send a message via MSN to CDHBookingEdge
Exclamation XML/DB data access question(s)

Ok I'll admit that my head is kind of reeling right now so I'll do my best to explain what I'm trying to do here. Please bear with me. I think one thing that's going on is I'm trying to solve too many problems at one time.

Let me try to explain. I seemed to be having some coldfusion problems so I'm unable to access some data for a customer. So then I obtained the database, or a sample of it, in Access Format (as an Access DB). Then when I got that, I thought for a bit and said to myself "Self, how the <bleep> are you going to get the data from an Access DB into the Flex progam?" Good point. So then I took that data and exported it into an XML file. Organized it nicely (cuz MSAccess sucks exporting to XML at least for my purposes.) So now I'm sitting here with an XML file

Now before I get to the more immediate problem let me say something that has been bugging me. Shouldn't there be a more generic concept in use here? Am I totally missing something here? I guess the best way to explain it is thru a kind of ADO concept. Something to relatively generically access data from different data sources. Just a question/idea to throw out to everyone.

As far as the immediate problem, here's the deal.

I've got an XML File in the following format:
Quote:
<list>
<month name="Apr-06">
<company ID="01">
<record conf#="1111" (other attributes as well) />
<record conf#="22222" (other attributes as well) />
<record conf#="62598" (other attributes as well) />
</company>
<company ID="757">
<record conf#="333" (other attributes as well) />
<record conf#="89452" (other attributes as well) />
<record conf#="45678" (other attributes as well) />
</company>
</month>
<month name="May-06">
<company ID="01">
<record conf#="1111" (other attributes as well) />
<record conf#="33333" (other attributes as well) />
<record conf#="48972" (other attributes as well) />
</company>
</month>
(other months...)</list>
Now I've got a dialog (popup/titlewindow) that's going to come up. It will be passed in the month that is desired and the company ID. The dialog is relatively simple, just containing a datagrid. The datagrid will hold information as far as the attribute for each record (theoretically record=row attribute=column).

So what I'm seeing is that first a "search" of the XML needs to be done. To put it SQL-ishly something like
Quote:
Select * from list where companyID="01" and month="Apr-06"
The question is, in my mind, how to do this and what's the best way to do this so that it is relatively independent of the means of data access.

I'm sorry if I'm being a bit unclear here. If I need to clarify things further please let me know. Any help would be much appreciated.

Christopher
CDHBookingEdge is offline   Reply With Quote
Old 11-02-2006, 06:53 PM   #2
meddlingwithfir
Senior Member
 
Join Date: Aug 2005
Location: Minnesota, USA
Posts: 216
Default

I'm by no means an XML expert when it comes to Flex, but it looks like they have the necessary classes to read and parse an XML file:

http://livedocs.macromedia.com/flex/2/langref/XML.html


From there, at the very least, you could set up a loop to run through your XML and grab whatever you needed. It unfortunately doesn't look like it has any XPath support though, which would have eliminated the need for looping over the child elements.
meddlingwithfir is offline   Reply With Quote
Old 11-02-2006, 07:05 PM   #3
CDHBookingEdge
Registered User
 
Join Date: Oct 2006
Posts: 383
Send a message via MSN to CDHBookingEdge
Default Thanks Med for the INFo

Yeah thanks medd..I got it figured out as far as the XML ...LOL finally...and they do have some ...well not Xpath but they have operators to be used...

here's a brief overview (skimpy I'll admit) of what I did
1) Load the XML using URLLoader (see documentation)
2) In result handler get the XML put in something like the following:
private function completeHandler(event:Event):void
{
try
{
var example:XML = new XML(event.target.data);
var ourList:XMLList = example.month.(@name == monthString).company.(@ID == compIDString).children();

ourData = new XMLListCollection(ourList);
}
catch (e:TypeError)
{
Alert.show("There was a problem in the completeHandler");
}
}
ourData was an XMLListCollection and then I put that in as the dataProvider for the DataGrid.

I think was really getting to me was the fact that I couldn't write "one set of code" for either an XML file as my source, or Access DB as my source or mySQL as my source, etc. Kinda ADO-ish I guess. But LOL I got over that in a hurry and got on to "getting the job done" now I'm working on other problems. You know how it is LOL

Thanks again, and take care (and I'll take a look at your post and see if I have any ideas),
Christopher
CDHBookingEdge is offline   Reply With Quote
Old 11-02-2006, 09:21 PM   #4
meddlingwithfir
Senior Member
 
Join Date: Aug 2005
Location: Minnesota, USA
Posts: 216
Default

Oh yeah, I know how that goes

For getting an ADO-like interface, ColdFusion has Datasources you can set up to handle different ... sources of data (Trying to think up another name for Datasources :P)... no matter where your data is (whether it's Access, MySQL, or MSSQL) you could use the same code.

Far as Flex having that functionality... I doubt that it does. Flex is supposed to be the "View" component of the Model/View/Controller design. It's not set up to directly interact with your Model (data) -- it should make requests to the Model through your Controller.

And hey, thanks for the reply to my debug thread... you have no idea how many headaches that's going to save me
meddlingwithfir is offline   Reply With Quote
Old 11-03-2006, 07:19 AM   #5
CDHBookingEdge
Registered User
 
Join Date: Oct 2006
Posts: 383
Send a message via MSN to CDHBookingEdge
Default

Yeah I think in a way I've been letting my "learning process" get in the way of my "getting the job done" process. I mean I pretty much jumped into this whole flex/flash/ria thing less than 2 weeks ago and I'm not saying to myself "Self, regardless of the language and technologies and such, what's the best organizational structures needed." And things like that. I've been reading a great book (And looking at tons of code and blogs et. al. on the web), the book is entitled "developing rich clients with macromedia flex" it's by Steven Webster and Alistair McCleod. They're the guys who did a lot of work on Cairngorm. I'd really recommend the book, even though it's dated 2004 and is for 1.5 a lot of the concepts still hold true today. I just wish I could figure out what happened to their website(s) (richinternetapps.com and iterationtwo.com) they seemed to be mentioned all over the place but every time I go to them they seem to be down.

Anyway was reading tonight (or this morning whichever you'd consider it, it was 2 am) about Value Objects and that's pretty much the way I'd been thinking. A set of data classes with strongly typed data members. So it looks like I'm slowly but surely adopting at least some concepts of Cairngorm LOL.

And I noticed the article I referenced in my post on the other thread worked for you. I'm glad to hear it.

Christopher
CDHBookingEdge is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Randomly Loading Questions from XML for Quiz. Dave At ADC ActionScript 2.0 0 12-14-2005 01:49 PM
arranging data from database in flash Heron ActionScript 2.0 1 08-02-2005 07:43 PM
Loading of data: Best methods? TheJazzMan ActionScript 2.0 1 07-25-2005 06:31 PM
More External Data Questions SpiderArts ActionScript 2.0 1 07-05-2005 05:28 PM
External Data SpiderArts ActionScript 2.0 1 06-30-2005 10:25 PM


All times are GMT. The time now is 02:08 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.