Wednesday 7 April 2010

Registering a remoteclass alias dynamically

Say you've got a value object (VO) and you have defined a remote class alias on it. You can change(add?) another alias dynamically at runtime.
When you perform the execution of a service call.

eg [RemoteClass(alias="lf.Project.Service.ServiceProxy.ObjectivesServiceProxy.StoreCluster")] on the class

com.fasanya.application.vo.StoreClusterVO.

To change this at runtime particularly useful if the same VO is used by different services you can do this...

public function execute(event:CairngormEvent):void  //often done in this method of a command
{

   var clientClassName:String = 'com.fasanya.application.vo.StoreClusterVO';

   var clientClass:Class = getDefinitionByName(clientClassName) as Class;

   var newAlias:String = ''lf.Project.NewService.NewServiceProxy.NewServiceProxyName.StoreCluster";

   registerClassAlias(newAlias, clientClass);

  ...other code...

  delegate.serviceRequest(clientClass);
}

Posted via email from fasanya's posterous

2 comments:

Varkey's said...

Great

I was looking for the same..

instead of registering from event I done it from application initialization..

thanks...

Unknown said...

Yes. Really great work, just I got this problem and your post helps me.

Thanks!