All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rwt.remote.RemoteObjectFactory.js Maven / Gradle / Ivy

Go to download

The Rich Ajax Platform lets you build rich, Ajax-enabled Web applications.

There is a newer version: 3.29.0
Show newest version
/*******************************************************************************
 * Copyright (c) 2012, 2013 EclipseSource and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    EclipseSource - initial API and implementation
 ******************************************************************************/

(function(){

var ObjectManager = rwt.remote.ObjectRegistry;

rwt.remote.RemoteObjectFactory = { // TODO [tb] : merge with Server.js? (not a factory)

  _db : {},

  getRemoteObject : function( target ) {
    var id = ObjectManager.getId( target );
    if( id == null ){
      throw new Error( "Invalid target for ServerObject, or target not in ObjectManager" );
    }
    return this._getRemoteObject( id );
  },

  remove : function( id ) {
    delete this._db[ id ];
  },

  _getRemoteObject : function( id ) {
    if( this._db[ id ] == null ) {
      this._db[ id ] = new rwt.remote.RemoteObject( id );
      this._initRemoteObject( id );
    }
    return this._db[ id ];
  },

  _initRemoteObject : function( id ) {
    var remoteObject = this._db[ id ];
    var handler = ObjectManager.getEntry( id ).handler;
    if( handler && handler.listeners ) {
      for( var i = 0; i < handler.listeners.length; i++ ) {
        var type = handler.listeners[ i ];
        remoteObject._.listen[ type ] = true;
      }
    }
  }

};


}());




© 2015 - 2024 Weber Informatics LLC | Privacy Policy