Sunday, March 15, 2009

Part 3 LCDS Insync Example, it works and I'm fed up.

Ok so I got this example to work and there was much rejoicing, followed by much disappointment but I'll save that for the end. There are a ton of steps, and missing one means it's not going to work so I'll try to lay it out for you.
  • Step One: First you need to create a project in flex builder. This really isn't that hard, just start a new air project and call it insync. When it's done just drag everything from the flex source into the src directory of your new project. Let it overwrite insync.mxml. There now you should have your very own project to play with.
  • Step Two: It's been a while since the original author wrote this insync sample so if you don't want an error that says:"error while loading initial content" then you need to go into your insync-app.xml. At the second line there is an application block, change it to say .
  • Step Two:Ok now you need the lcds libraries in your path or else you won't be able to compile against them. If you try you'll just get a bunch of errors which I forget at the moment but they basically say "GET THE LIBRARIES" :) So where are they? If you're like me they're hidden in the war files. Go to your lcds-samples.war file, and unzip it again. Now under the WEB-INF directory you just made by unzipping the file, there is a flex directory. Under that directory are two folders libs and locale. That's where your libraries are. You can copy them someplace else or leave them where they are that's up to you. Next you need to add them to your path. In Flex Builder go to project properties, then go to the Flex Build Path tab. Now you need to add two SWC folders, just click on the SWC folder button and add libs and locale. Now you need to add two SWC files. The first is the airfds.swc file, it's in that libs folder you just added, in the air directory. The last file you need to add is in the locale directory, under the en_US directory, and it's called fds_rb.swc. Just add that file and you're good to go
  • Step Three: At this point you should be able to build. So give it a shot. If you start up your jboss server from part two and start the sample database, then try to run your application you'll get this error: Error: Unable to initialize destinations on server: ["nameOfDataService"] Sigh more errors, unfortunately this one is a bug in lcds, and it's documented here You'll notice there are others that feel our pain, and at the bottom Jeff from Adobe invites people to email him to receive a fixed copy of a library. Which I did yesterday, which was Saturday so we'll see what I get back. In the meantime his advice to compile in your services descriptions led me to come up with the following modifications to the compiler command line. Just go back to Project --> properties in Flex Builder. Now under the Flex Compiler tab, add this to Additional Compiler Arguments: Fill in your directory paths: -locale en_US -services {your path to jboss}/jboss-4.2.2.GA/server/default/deploy/{your directory you unziped lcds-samples.war to}/WEB-INF/flex/services-config.xml -context-root=http://localhost/ Mine looks like this: -locale en_US -services /Users/Downloads/jboss-4.2.2.GA/server/default/deploy/test26/WEB-INF/flex/services-config.xml -context-root=http://localhost/
Ok well now at this point you should be able to compile and run the program yourself. You should see the data populate into the application, and if you see the little green online light in the bottom corner you should be able to make changes. I was pretty happy at this point so I decided to try a little testing, and of course more issues. I don't think it's the original authors design, but more some lingering issues with LCDS but that's just one mans opinion. Try this little test, start your application with the server running and get the contact data, then shutdown the server to simulate a loss of connection. Now add a contact in the insyc application and close it. Now according to the theory when we start up I'd think it would load the contacts from cache since it's offline and if the server is online it should update the sampledb. Not so, if you try to startup with the server started you'll get a couldn't fill message. If you're inclined to dig a little further and debug it you'll see messages about it not being able to initialize the datasource. If you want to fix your problem just go delete the sqlite database it's using. On a mac that's under. /Users/username/Library/Preferences/insync/Local Store/_ds_localstore You'll see the file you want is named after the datacache id set in your insync program. So this is where I stopped, lcds was incredibility complicated to setup, and it seems like there are still bugs to be worked out. These are exactly the type of problems I'd hoped to avoid by using it. So my conclusion is that for what I want to do it's a lot easier to just write it myself. I'm thinking I'll just post signed XML requests to a PHP script for proof of concept, then when I want it to go faster I'll just write a server in C. I hope this helps at least someone out there. Good Luck

No comments:

Post a Comment