Specifying an endpoint for a RemoteObject destination at runtime

June 5, 2008

When you intend to use BlazeDS or LCDS in your App, you usually start a new project in FlexBuilder and set the Server Technology to LCDS and then Set the Root folder and Context root and validate the configuration to create the project as below.

At this point, FlexBuilder adds a -services option to the compiler and sets it to the services-config.xml where the end-points for the services are set.

You can then write code as below where the destination is now configured in the config file that’s set at the location in -services option.

<mx:RemoteObject id=”artJava” destination=”ArtGallery” fault=”errorHandler(event)” showBusyCursor=”true”>
<mx:method name=”getArts” result=”onArtResult(event)”/>
</mx:RemoteObject>

If you look into the services-config.xml you will see the following lines there

<channel-definition id=”my-amf” class=”mx.messaging.channels.AMFChannel”>
<endpoint url=”http://{server.name}:{server.port}/{context.root}/messagebroker/amf” class=”flex.messaging.endpoints.AMFEndpoint”/>
<properties>
<polling-enabled>false</polling-enabled>
</properties>
</channel-definition>

When you run the app in FlexBuilder, it substitues the {server.name} and other variables from the configuation that you set when you created a new project and compiles this into the application. This works like a charm, but this has a problem.

Yesterday, I did an application and bundled it into a war file and send it to my friend. But when he ran it, it did not work. This was because, I had my BlazeDS installed on port 8400 while he had it on port 8080. Since my Builder had substituted the {server.name} at compile time, the only option was to give him the whole project and get him to recompile it for his configuration.

Thanks to Sujit, I discovered that you can not go this way and make this generalized by injecting these values at runtime, rather that these being at compiletime.

The trick is Read the rest of this entry »

Advertisements

index.template.html and its significance in Flex Project Development

March 5, 2008

I had posted a couple of posts earlier (the contextMenu based fullscreen & the fullScreenVideo) where it required you to edit the html wrapper in which the Flex App SWF is embedded. A lot of people came back to me saying that they still were getting the following error whenever they re-ran the app, even though they had edited the html source …

SecurityError: Error #2152: Full screen mode is not allowed.
at flash.display::Stage/set displayState()

So, I wanted to discuss here, why this error is occurring and also discuss a couple of things about html generation in FlexBuilder.

In FlexBuilder3, if you look at the project tree you will see a folder called “html-template“. This folder contains the following files..

  • AC_OETags.jsA JavaScript source file used by client to detect and embed the Flash Player
  • playerProductInstall.swf This implements the Flash Player Express Install mechanism which comes into play if the client does not have the required player
  • index.template.html -HTML template that is used by the FlexBuilder to generate the wrapper html for all the application files in your project.

The error discussed in the beginning is caused by the last mentioned file. Whenever FlexBuilder compiles an app, it verifies the signature of the wrapper html to the index.template.html. if there are any variations, it recreates/overwites the html file to match the template.

So, any changes that you might have made on the html is lost whenever you run the application and hence the error. There are various ways of solving this.

  1. The easiest way out is to create your own wrapper html and use that instead of the default wrapper generated. You can copy the code and then extend it with your additions on it…
  2. The above way is recommended if your project has a lot of applications inside it. But, if your project hosts only one application and other files supporting it, it would be better for you to go ahead and edit your index.template.html itself, which would then reflect in your wrapper file without any hassles.

You can also read this post by Mike Morearty on “ Changing the filenames in Flex Builder html templates” which will provide some more insight into the html-template…


Changes in Flex 3 licensing model

February 19, 2008

There have been several changes from Flex2.0.1 to Flex 3. In this post, I’ll discuss about the packaging changes in Flex Builder(FB) and the changes in licensing for the product.

Packaging changes in Flex 3

In Flex 2, we had the following types of packaging…

  • Flex Builder 2
  • Flex Builder 2 with Charting
  • Flex Charting 2

    In Flex 3, it has become as below…

    • Flex Builder Standard
    • Flex Builder Professional

      This means that the Flex Charting product that existed in 2.0.1, no longer exists as a standalone buy in Flex 3. Instead, it is packaged in the Data Visualization package (which includes Charts & its enhancements, AdvancedDataGrid, OLAPGrid… etc) which is available only with the Flex Builder Pro.

      Over and above the standard edition, the professional edition will provide premium features like Charting and Visualization components, the Profiler, and the Flex Test Automation Framework. If you need more info about prices and stuff, you can check out this post by Ted. A thing to note here is that the Automated Testing Framework is available only with the FB Pro & also that this would be the only way of buying the Automation framework of rhe product…

      FB & Data Visualization Licensing and the “licenses.properties” file

      Now, let’s talk about the licensing. In Flex2, if you had the charts.swc then you could write applications using the charting framework. But this would lead to a trial watermark to be displayed on the chart as below, which would make it useless for production applications.

      Charting Watermark

      The way to get rid of this was to get a Flex Charting license and then add it in the “Manage Flex Licenses” tab in Flex Builder 2 or add it in the license.properties file in the “\sdk\frameworks” directory.But with FB3, a whole new set of work flows emerge.

      1. If you need to use charting in FB3 using Flex3 SDK, things are a breeze. You can install FB Pro, and enter the serial no in the “Manage Flex Licenses” tab in the “Help” Menu and you are ready to roll.

      2. But, FB3 also supports multiple-sdks in it. It comes pre-installed with Flex 3 & Flex 2.0.1 sdks (you can find it in the “\sdks” directory). So you may want to still continue working with Flex 2.0.1 project in FB3. If that project has charting, you will still see the watermark, even if you enter the FB3 Pro serial. This is because the Flex 2.0.1 SDK takes the charting serial from the licence.properties file in its SDK directory (“\sdks\2.0.1\frameworks”). So the way to work around this is to enter your Flex 2 charting license in the file.

      Also, another thing to note is that if you want to manually enter the FB license in the license.properties file in Flex3, the file is now stored in a global location in the OS and not in the frameworks directory in the SDK path. The path to the license.properties file for various OS’ are given below.

      • “../Documents and Settings/All Users/Application Data/Adobe/Flex” directory on Windows
      • “Library/Application Support/Adobe/Flex” directory on MAC
      • “$HOME/.adobe/Flex” on Linux

      Happy New Year…

      January 2, 2008

      Just back from a vacation to my hometown… I have been un-plugged from the web for the past week.

      I was trying to catch up with some happenings in the RIA world and came across some posts which I thought I should share here

      HAPPY NEW YEAR to everyone…


      Free registration of FlexBuilder2 with Charting for Students & Faculty

      November 26, 2007

      Some timeback, I had written about Adobe’s announcement on providing FlexBuilder2 free of cost to students and faculty of educational institutions. I had promised more info on this, so here it is.

      First, the great news!! Adobe is giving you not just a FlexBuilder license, but also the Charting package along with it. This is great news as you can now make really awesome applications like the showcase dashboard easily. Here’s what you should do…

      1. Go ahead and create an Adobe ID here (ignore this if you already have one)
      2. Use the same page to sign in
      3. Go to the this link and download FlexBuilder & the Flex Charting package.
      4. Now go to flexregistration.com and register your product as a student or faculty
        • If you are a student, you would need to upload scanned image (GIF or PDF) of the front of your Student ID stating a current date. If you do not have a Student ID please upload a scanned image (GIF or PDF) of a letter on your educational institutions letterhead that verifies that you are a current student at the institution
        • If you are a faculty, you would need to upload scanned image (GIF or PDF) of the front of your Faculty ID stating a current date. If you do not have a Faculty ID please upload a scanned image (GIF or PDF) of a letter on your educational institutions letterhead that verifies that you are a current Faculty at the institution
      5. This info will be verified and then you can get the license key for the software.

      On the same note, here are some other resources that students and faculty can leverage if they are interested in Flex.

      Do try it out and let me know if there are any issues or queries.


      FlexBuilder to be offered free to students

      October 26, 2007

      This is one news that I wanted to shout from every rooftop, the day I heard it. But I’ve had to restrict myself, but no more !!!

      Adobe announced that it is offering FlexBuilder2 at no cost to students and faculty at educational institutions worldwide. This would be made available starting early November this year. The official press release is available online at Yahoo News


      How do I get Data Visualization Charting Components for FB Linux?

      October 3, 2007

      I was reading the FB Linux FAQs and came across the question that became the title of this post. The answer was…

      While the Data Visualization and Charting components are not part of the Flex Builder Linux Alpha, it is possible to purchase a Flex Builder 3 Professional license (either Mac or Win) and move the licensed datavisualization.swc file over to your Linux installation. This process has been explained by various users in our forums and is acceptable under the terms of your Flex Builder 3 license.

      This answer didn’t make me happy. I tried googling for the exact solution, but in vain. So I decided to post the solution myself. Here it is. The trick to make this work lies in 2 swc files existant in your Flex SDK Folder.

      Pre-Requisite: You need to have an SDK with Data Visualization Charting Components already installed.

      When you install FlexBuilder on Windows/MAC, it already comes the Data Visualization Charting Components installed, but with a watermark on them. If you have the serial number, then the watermark goes away. Now this is what you need to do…

      Caution: Please make sure that your SDK installations on Linux & Win/Mac are compatible before you follow the steps below. To do this go to [FB Install Folder]/sdks/3.0.0/bin folder and type the following on the command-line (or terminal) to ascertain the version numbers are the same.

      mxmlc -version (on WIN)

      ./mxmlc -version (on MAC/Linux)

      Steps to Install Data Visualization Charting Components for Linux

      1. Go to the [FB Install Folder]/sdks/3.0.0/ folder on your WIN/MAC
      2. Get the following files…
        • [FB Install Folder]/sdks/3.0.0/frameworks/libs/datavisualization.swc
        • [FB Install Folder]/sdks/3.0.0/frameworks/locale/en_US/ datavisualization_rb.swc
        • [FB Install Folder]/sdks/3.0.0/frameworks/license.properties
      3. Copy this to your FB Linux installation in the same directory structure as above

      This should get Data Visualization Charting Components working on Linux, complete with code-hinting. Let me know if you have any problems.

      Addendum: I had overlooked the need for continuing to use Charts in Flex2.0.1 on FlexBuilder. In that case, you can copy the file [FB Install Folder]/sdks/2.0.1/frameworks/libs/charts.swc to the same location in the 2.0.1 SDK delivered with the FB Linux. You can also copy the file [FB Install Folder]/ sdks/ frameworks/ license.properties from your 2.0.1 SDK in Windows to the same location in the 2.0.1 SDK in Linux. This should get rid of the watermark if you have a license.