26 December 2008

Step 4 - Create a Flex application

Now we're getting into the interesting bits. 
First we create our first Adobe LiveCycle Data Services Flex application.
Make sure you Validate the configuration. The directories should be all the same (at least in this examlpe.
Now, add the datamodel var inventory:ArrayCollection and the view mx:DataGrid. For DataGrids with given column names, I often include a mx:Label to indicat whether I actally received any data, or if just my DataGrid isn't displaying waht I received.
Then we include the <mx:DataService id="ds" destination="sql-product"/>
And finally, we're filling it in the onCreationComplete()
and don't forget to trigger the event in creationComplete="onCreationComplete() the <mx:Application>.
The final code should look like this: 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
creationComplete="onCreationComplete()">
<mx:Script>
<![CDATA[
  import mx.collections.ArrayCollection;
  [Bindable]
  protected var inventory:ArrayCollection = new ArrayCollection();

  protected function onCreationComplete():void {
      ds.fill(inventory, "all");
  }
]]>
</mx:Script>
<mx:DataService id="ds"
destination="sql-product"
/>
<mx:DataGrid id="grid1"
dataProvider="{inventory}"
editable="true"
/>
<mx:Label text="Items: {inventory.length}" />

</mx:Application>
And your application should look like this:
Update the data
Now start the Admin application (http://localhost:8400/lcds-samples/sqlassembler/index_inv.html) in another window, and update som of the info. Watch you new application!
Troubleshooting
If you receive the error:
An error executing SQL caused the operation to fail. If debug level logging is enabled for the SQL Assembler, details are logged on the server.
Make sure you start the Sample Database BEFORE you start Tomcat. Check the log windows for LCDS if you find :
******************************************************************************
*                                                                            *
*  Unable to connect to the samples database.                                *
*  You must start the samples database before you can run the samples.       *
*  To start the samples database:                                            *
*    1. Open a command prompt and go to the {install-dir}/sampledb dir       *
*    2. Run startdb.bat (Windows) or startdb.sh (Unix-based systems)         *
*                                                                            *
******************************************************************************
Turn on debugging in HSQLDB (previous post) to find out if LCDS actually finds the DB at all. 
(In my case I got 'Access denied' because I had changed the sa password.... :)
[Main article] [Next] [Previous

Labels: , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home