close

Filter

loading table of contents...

Studio Developer Manual / Version 2404

Table Of Contents

9.31.3 Implementing Studio Remote Beans

You can now create custom remote beans which are linked to the corresponding EntityControllers.

Every remote bean consist of an interface and an implementing class. For the note model, the files Note.ts and NoteImpl.ts would look like:

import RemoteBean from "@coremedia/studio-client.client-core/data/RemoteBean";

abstract class Note extends RemoteBean {

  abstract getDescription():string;

  abstract getUser():string;

  abstract getNoteId():string;
}

export default Note;

Example 9.125. Abstract class of Note remote bean


with the implementing class

import { mixin } from "@jangaroo/runtime";
import RemoteBeanImpl from "@coremedia/studio-client.client-core-impl/data/impl/RemoteBeanImpl";
import Note from "./Note";

class NoteImpl extends RemoteBeanImpl implements Note {
  static readonly REST_RESOURCE_URI_TEMPLATE: string = "notes/note/{id:[^/]+}";

  constructor(uri:string) {
    super(uri);
  }

  getDescription():string {
    return this.get("description");
  }

  getUser():string {
    return this.get("user");
  }

  getNoteId():string {
    return this.get("noteId");
  }
}
mixin(NoteImpl, Note);

export default NoteImpl;

Example 9.126. Implementing class of Note remote bean


When implementing remote beans, you have to make sure that the URI path of the remote bean described in the constant REST_RESOURCE_URI_TEMPLATE.

[static readonly REST_RESOURCE_URI_TEMPLATE: string = "notes/note/{id:[^/]+}";]

Example 9.127. Remote Bean URI path


matches the REST URL of the Java controller entity class.

In the last step, Studio has to register this class as a RemoteBean. Studio comes with a plugin for that, so simply add the following line in the init section of your Studio plugin or the init.ts file or your plugin module:

BeanFactoryImpl.initBeanFactory().registerRemoteBeanClasses(NoteImpl)

Example 9.128. Register class as remote bean


You can now use your custom remote bean within components to render a note's description.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.