close

Filter

loading table of contents...

Studio Developer Manual / Version 2210

Table Of Contents

9.31.4 Using the EntityController

Before using the newly created remote Bean inside a component, let's see if the REST request is actually working. You can test this by logging into Studio, open a new tab and invoking the following URL: http://localhost:43080/rest/api/notes/note/1 (the path may differ depending on your setup)

The result should look like this:

{
  "description": "I have to find a real storage for this!",
  "owner": "me",
  "noteId": "1"
}

Example 9.127. Result of Note


The URL segment api/ is configured for all Studio REST controllers and ensures that all REST request are located under one unique segment.

So your EntityController is working and you have declared a RemoteBean for it. Now, invoke it from TypeScript.

You can simply use the base class of your Studio plugin rules (if available) or any other component base class that is created just to quickly test your code.

const note = as(beanFactory.getRemoteBean('notes/note/1'), Note);
note.load((loadedNote):void => {
  console.log(`My note says: ${loadedNote.getDescription()}`);
});

Example 9.128. Invoke class from TypeScript


Note that the invocation of the remote bean is done without the api segment. Remote beans have to be loaded manually or via ValueExpressions. Compile your workspace with this code and reload Studio. You should see the following message on your browser console:

My note says: I have to write a real storage for this!

Example 9.129. Output from remote bean


Next, use the remote bean inside a component:

Config(DisplayField, {
              plugins: [
                Config(BindPropertyPlugin, {
                  componentProperty: "value",
                  bindTo: ValueExpressionFactory.create('description',
                    beanFactory.getRemoteBean('notes/note/1')),
                }),
              ],
            }),

Example 9.130. Remote bean used inside a component


This example creates a label which contains the description of your note. Usually RemoteBeans are always accessed through a ValueExpression. The ValueExpression is then responsible for loading the value out of the RemoteBean.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

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