Creating a Client Command Handler on WebMap4

This assumes that you already have a ClientCommand handler for clientdownload.
If you dont then do something like on the WebMap4:

  • Create a new App Client
export class SampleApp extends Mobilize.WebMap.Kendo.App {  
  constructor() {
    super();
  }
}
  • Create a command that maps the JSON response and data object
export class ClientDownloadCommand implements Mobilize.Contract.UI.ICommand {  
    private _url: string;
    constructor(data: any) {
       this._url = data.TargetURL;
    }

    get url() : string {
       return this._url;
    }

    get name() : string {
      return "clienturlopen";
    }
}
  • Register an action associated with the command
export class SampleApp extends Mobilize.WebMap.Kendo.App {  
  constructor() {
    super();
    this.onCommandRegister = this.CommandRegister;
    this.viewHandler = this.viewManagerRegister;

  }
  CommandRegister(factory: Mobilize.Contract.Ui.ICommandFactory)
  {
  factory.register("clienturlopen", ClientDownloadCommand);
  }
  viewManagerRegister(viewManager: Mobilize.Contract.Ui.IViewManager){
   super.viewHandler(viewManager);
   this.viewManager.registerCommand("clienturlopen", command => 
     this.processCommandForClientDownload(command as ClientDownloadCommand);
  }
  processCommandForClientDownload(command: ClientDownloadCommand) {
     window.open(command.url); 
  }
}