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: , , ,

17 December 2008

Step 3 - Get to know the existing sample HSQLDB database

Once you have started your Livecycle Data Services (LCDS) and HSQLDB database agent (more here), you can explore the two Flex applications contected to the product sample database. Open the following in two different browser windows, do some changes in the Admin page, and see the changes imidiately in the shop.
The database, HSQLDB, is a built-in, mature open source database engine.
Our sample
...uses only one table, 'PRODUCT'. This table and all other data, table definitions, user rigts etc of the database, are simply defined in a text file:
C:\Adobe_lcds\sampledb\flexdemodb\flexdemodb.script.
This file contains the product data well as date for the Employee and Cencus applications. Therefore there will be more data than what you rcognise, right away. Don't worry about it. Just consentrate about the lines containing 'PRODUCT'.
Altering the database
You can add your own tables, rows, users just by editing the text file, and restert the database agent.
Add 'CREATE TABLE' statements for your own tables, and 'INSERT INTO's for your data. Just follow the concept as the existing tables use.
In flexdemo.script you can also change the SA password, but don't do that unless you also changes the password in your LCDS!
Database setup
The HSQLDB that comes with LCDS is set up with two databases: FlexDemoDB and SalesBuilderDB. This is configured in: C:\Adobe_lcds\sampledb\server.properties.
Change to server.silent=false and server.trace=true if you need more debugging info.

14 December 2008

Step 2 - Understand LCDS' folders

If you are completely new to Adobe LiveCycle Data Services and Java application servers in general, I hope this might be a few guiding lights in the dark. What is a Java Application Server? Think of it as a web server (IIS if you like), but with lots of built in functionality, modules and library function that your "web pages" can use. LiveCycle Data Services (LCDS) is one such a library of functionality. In this turn-key installation of LCDS, we use Tomcat as the Java application server. So LCDS runs within Tomcat. Java application servers are basically folder and file based, and at first glance it is difficult to know what each folder is for and where to put your own applications. Where do I start? Where do I put my stuff? First the application server Tomcat:
C:\Adobe_lcds\tomcat The root folder for Tomcat, your Java application server
C:\Adobe_lcds\tomcat\bin Directories for Tomcat startup/shutdown scripts
C:\Adobe_lcds\tomcat\conf Configuration files for Tomcat
C:\Adobe_lcds\tomcat\work Hands off! Tomcat's own temp (working) folder
More info about Tomcat at Jajakarta.org
And now what we are interested in... LCDS:

C:\Adobe_lcds\tomcat\webapps

Root folder for LCDS.

C:\Adobe_lcds\tomcat\webapps\lcds-samples

Adobe's sample applications.

http://localhost:8400/lcds-samples/

C:\Adobe_lcds\tomcat\webapps\lcds

Template folder for your own apps. Copy this, and create your own based on this template. Keep this unspoilt if you need to start from scratch.

http://localhost:8400/lcds/

C:\Adobe_lcds\tomcat\webapps\ds-console

The console / status reports for the Adobe LiveCycle Data Services web applications.

http://localhost:8400/ds-console/

More info about LiveCycle Data Services configuration at Adobe
Next we will look at the database sample that came with LCDS. [Main article] [Next] [Previous]

Labels: , ,

13 December 2008

Step 1 - Download and install Adobe LiveCycle Data Service The very first step on how to get started with Adobe LiveCycle Data Servces (LCDS). Select the Single-CPU / Trial version from http://www.adobe.com/downloads/.
  1. Start 'lcds261-win.exe'
  2. Leave the serial number blank (free when used on a single CPU)
  3. Install with Tomcat (unless you know how to do otherwise)
  4. My example uses the install path C:\Adobe_lcds.

Start LiveCycle Data Services Server and Samples Database

  1. Start - Adobe - LiveCycle Data Services ES 2.6.1 (or C:\Adobe_lcds\tomcat\bin\catalina.bat start)
  2. Start - Adobe - Start Samples Database (or C:\Adobe_lcds\sampledb\startdb.bat start)

Test LCDS

My default installation gives me LCDS on http://localhost:8400/, which is configured in C:\Adobe_lcds\tomcat\conf\server.xml, under Service name "Catalina".

LCDS Samples are found on http://localhost:8400/lcds-samples/. And our applications will be deployed at http://localhost:8400/lcds/.

Check also out the console on http://localhost:8400/ds-console.

[Main article] [Next] [Previous]

Labels: ,

12 December 2008

How-to connect LiveCycle Data Services 2.6 to Microsoft SQL Server

Flex is front-end only. So, when you want to get information from one of your databases, you need 'something else' to transport your data between the database and the Flex front-end. This 'something', you often have to make from scratch, and names and structure are often partly redundant, as it copies existing code, written in ActionScript/Flex.

Adobe LiveCycle Data Services is capable of providing this missing link, without writing a single line of code, by using its SQL Adapter. You specify SQL statements directly in a configuring file, for Creating, Reading, Updating and Deleting information (CRUD).

Here in Scandinavia, "all" databases are Microsoftified, therefore I would very much like to connect to Microsoft SQL Server. Though, finding examples for connecting to MSSQL wasn't that easy. 

 

Being a newbie to Flex, LiveCycle Data Services and Java application servers in general didn't make it easier. But I've succeeded, and here's my story for others in the same situation:

1. Download and install Livecycle Data Services  2. Understand the folders of LCDS and Tomcat, the java app server 3. Explore the existsing sample HSQLDB database and its configuration 4. Create a Flex application reading the sample database 5. Install MSSQL Java drivers 6. Set up MSSQL and LCDS' connection As you see, I'm not yet finished writing all the sub sections. But they will come...

 

Labels: , , ,