Announcement Announcement Module
No announcement yet.
Externalizing a channel URL Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Externalizing a channel URL

    I'm currently writing a tutorial series about how to integrate Grails and Flex. First episodes are here and there.

    In the second episode, I have to configure the channelSet of my RemoteObject inside MXML in order to reference it for authentication purposes:

    <services:TodoListService id="todoListService" 
    			fault=" + '\n' + event.fault.faultDetail)" 
    				<s:ChannelSet id="channelSet">
    					<s:AMFChannel url="http://localhost:8080/todolist/messagebroker/amf"/>
    But of course, the problem with that approach is that I'm hardcoding the URL of my AMFChannel, which makes it hard to have several build configurations with different URL's for each target environment.

    I figured Spring Actionscript could help me with that by allowing me to configure this URL in an XML or properties file so that I can choose which configuration to choose depending on the environment.

    Is my assumption right? How should I proceed?

  • #2

    Hey Sebastien,

    you are indeed correct in your assumptions

    Check this doc section out for channel configurations:

    And here is some information on externalizing properties:

    Good luck with your article and if you need any more help or advice, please feel free to ask us at any time.




    • #3
      I'm trying to figure out how to make this work. Here is what I did so far:
      - I created an application-context.xml file with the following content:

          <object id="amfChannel" class="mx.messaging.channels.AMFChannel" scope="singleton">
              <constructor-arg value="my-amf"/>
              <constructor-arg value="http://{}:{server.port}/todolist/"/>
              <property name="id" value="amfChannel"/>
              <property name="pollingEnabled" value="false"/>
          <object id="channelset" class="mx.messaging.ChannelSet" scope="singleton">
              <method-invocation name="addChannel">
      - I added a ContextURL flashvar in my html template:

      <script type="text/javascript">
                  <!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. -->
                  var swfVersionStr = "10.0.0";
                  <!-- To use express install, set to playerProductInstall.swf, otherwise the empty string. -->
                  var xiSwfUrlStr = "playerProductInstall.swf";
                  var flashvars = {ContextURL:"application-context.xml"};
                  var params = {};
                  params.quality = "high";
                  params.bgcolor = "#ffffff";
                  params.allowscriptaccess = "sameDomain";
                  params.allowfullscreen = "true";
                  var attributes = {};
         = "Main";
         = "Main";
                  attributes.align = "middle";
                      "Main.swf", "flashContent",
                      "100%", "100%",
                      swfVersionStr, xiSwfUrlStr,
                      flashvars, params, attributes);
      			<!-- JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. -->
      			swfobject.createCSS("#flashContent", "display:block;text-align:left;");
      - Then in my MXML application, I added a couple of event handlers:

      protected function preinitializeHandler(event:FlexEvent):void
      				_contextURL = parameters['ContextURL'];
      			protected function applicationCompleteHandler(event:FlexEvent):void
      				var applicationContext:XMLApplicationContext = new XMLApplicationContext();
      				applicationContext.addEventListener(Event.COMPLETE, contextLoadedHandler);
      			protected function contextLoadedHandler(event:Event):void{
      				todoListService.channelSet = ( as XMLApplicationContext).getObject("channelset");
      So basically, my application-context.xml is correctly located thanks to the flashvar. Then my application context is correctly loaded and 2 beans are initialized. Then my todoListService is successfully assigned a channelSet (or at least I don't get any error message telling me otherwise). But then when reloadTasks() runs, which calls my data service to load data for the first time, I get an error saying:

      Send failed
      Channel.Connect.Failed error NetConnection.Call.BadVersion: : url: 'http://localhost:8080/todolist/'
      Any idea what the problem might be?


      • #4
        I found my mistake. The URL of my AMF endpoint was wrong.