Monday, March 31, 2008

AIR & LCDS - How do they work together?

,,,

Its easy to get started with Flex App and LCDS (i assume you know how to).. Use Flex Builder and create a J2EE Project with Remoting enabled. Use the LCDS setup install path for the context root in your dialog and set up the project.

Typically if you make a Flex Application you would ensure that your output directory of the generated SWF lies in the folder location inside the /flex directory or /samples/ directory of your flex application. Relevant config files have to be picked up ... I will describe the configuration files here in brief about LCDS:

-> service-config.xml - Main xml file that includes the below xml files and references them
-> remoting-config.xml - Used for writing destinations of Java/AS mappings using mx:RemotObject
->proxy-config.xml - Used for writing destinations for mx:HTTPServlet/mx:WebService
-> messaging-config.xml - Used to write destinations for mx:MessageProducer, mx:MessageConsumer
->data-management-config.xml - for DataService, fill operations

All these files reside in : C:\lcds\jrun4\servers\default\flex\WEB-INF\flex (On Windows) and /home/username/lcds/jrun4/servers/default/flex/WEB-INF (On Linux) (All this if you are running LCDS 2.5.1)

Using Flex Builder, You can Create an AIR Project with J2EE, LCDS Enabled for the project. So what happens? Your subscription to destinations may not work!! The same stuff on Flex Project works fine. So how do you rectify it?

AIR Projects need some extra settings in-order to work with LCDS -

A) Copy the services-config.xml from the above locatoin on the server to your project 'src' directory.
B) Raneme the copied file as 'custom-services-config.xml'
C) Open the menu in flex builder, Project->Properties
D) Go to the Compiler settings and you will find that the 'services-config.xml' need to be modified to include this one in the new path. i.e., set it as 'custom-services-config.xml'
E) Open the custom-services-config.xml file and look at your default channel (protocol). If you are using 'my-polling-amf' or 'my-rtmp', ensure that you remove the dummy 'http://{server-name}:port' and change it to 'http://localhost:portnumber or http://ip-address:portnumber' (similarly rtmp://{server-name}:port' to rtmp://localhost:portnumber or rtmp://ipaddress:portnumber)
F) Ensure that you have set your Default Channel accordingly as you altered.
G) Also, along with the custom-services-config.xml you would need remoting-config.xml, messaging-config.xml, data-management-config.xml. Copy them all to your local project src directory.
H) Ensure that you write all your destinations two times. One in the local copied files (related config file), and the remotely available config files.

Most problems related to changing of Protocol in LCDS occur due to "NOT CLEANING the Project and re-compiling it". As you change the compiler properties to include custom-services.config.xml, you would have already enabled auto-compile option. So this change will not recompile it unless you make changes to your app. So Ensure that you clean your project and recompile it.

Wednesday, March 26, 2008

Compiling and Running an AIR application on Linux (using sdk)

"Compiling and Running an AIR application on Linux (using sdk) is same as how you do it on Windows". If you have Flex Builder, you dont have to worry about this. BTW, this post is only for beginners on AIR. If you want to compile and run the app using the sdk (terminal on linux, cmd on windows), Here is how you do that.

a) Get the SDK downloaded to a locatoin (ex: /home/username/flexsdk/)
b) If you are installing Flex Builder Linux Alpha 3 (to be released in labs around 31 March), you have an inbuilt sdk in your install location (ex: $INSTALL_LOCATION/Adobe_Flex_Builder_Linux/sdks/3.0.0)
c) Use the "amxmlc" - AIR MXML compiler present in your sdK (ex: $INSTALL_LOCATION/Adobe_Flex_Builder_Linux/sdks/3.0.0/amxmlc)
d) Assuming you have created an AIR MXML Application with its application properties file AIR XML file. (locatoin ex: /home/username/AIRApps/FirstAirApp/MyApp.mxml, MyApp-app.xml)
e) You will have to find AIR runtime directory (if you have installed Flex Builder on Linux alpha 3, Then runtime directory = $INSTALL_LOCATION/Adobe_Flex_Builder_Linux/sdks/3.0.0/runtimes/air/Linux),
e) Open your Terminal (cmd prompt on windows)


To Compile your MXML File

f) $localhost@terminal>"$INSTALL_LOCATION/Adobe_Flex_Builder_Linux/sdks/3.0.0/bin/amxmlc" <space> /home/username/AIRApps/FirstAirApp/MyApp.mxml
g) It will generate a SWF file with the same name in your directory (from where you are compiling)

Configure your *-app.xml to point it to the generated SWF
h) Open the application descriptor file "/home/username/AIRApps/FirstAirApp/MyApp-app.xml" (either in vi editor or in text editor), Find the string "[This value will be overwritten by Flex Builder in the output app.xml]" with in the tags <content> nested inside <initialWindow>. Remove the string present in the <content>...</content> and replace it with the path to the SWF file generated after you have compiled it. (example: <content>/home/username/....../Myapp.swf</content>). Save the file.

Running your air app:
i) In Your terminal run the command :
localhost@username> $INSTALL_LOCATION/Adobe_Flex_Builder_Linux/sdks/3.0.0/bin/adl_lin <space> -runtime <space> $INSTALL_LOCATION/Adobe_Flex_Builder_Linux/sdks/3.0.0/runtimes/air/Linux <space> /home/username/AIRApps/FirstAirApp/MyApp-app.xml

There you go... Your AIR App is launched for you.

PS:Please note that AIR Runtime (packaging/installing air apps etc.) does not come with Flex Builder Linux installation. You can get AIR Runtime for Linux on labs once again.


Wednesday, March 19, 2008

Flex Builder Linux - Alpha3

The Alpha3 version of Flex Builder for Linux is gonna hit the public users on LABS.ADOBE.COM around March 31th 2008. So what would it comprise of?

As the version still stays at alpha, dont expect really much. No Design View as yet. But yet, something exciting to speak - Support for AIR in flex builder.. plus some bug fixes...

Hope you will like the addition of AIR and provide us your feedback as always...