English English Spanish EspañolKorea한국어
Straker»Company»Blog»2005» RemoteObject and its source attribute

RemoteObject and its source attribute

I wanted to be able to read the "source" attribute of the RemoteObject tag from an XML file. So I first read the XML file into the model:
<mx:Model id="portalConfig" source="portal-config.xml"/>
The contents of the xml file are:
<config>
   <site>uosmx</site>
   <gateway>
      <sof>uosmx.app_templates.objects.shadoportal.SOFGateway</sof>
      <nof>uosmx.app_templates.objects.shadoportal.NOFGateway</nof>
   </gateway>
</config>
And I setup my RemoteObject tag thus:
<mx:RemoteObject id="sessionService" source="{portal-config.gateway.sof}" endpoint="@ContextRoot()/flashservices/gateway?">
      <mx:method name="getNOFObject" result="handleNOFResult(event.result)"/>
   </mx:RemoteObject>
However, the Flex compiler does not "evaluate" {portal-config.gateway.sof}. Scott (Mr SynergyFlex) suggested the following solution that worked. In the function that invoked the remoteobject, one needs to trick the compiler into picking up the new value by doing the following:
function doLogin(){

      // this is the only way remote objects will take a value from a binding.       sessionService['__serviceName'] = XMLConfig.gateway.nof;
      
      var call:Object = sessionService.get();
   }


Comments

There are no comments for this page as yet.

Add a comment