Studio Developer Manual / Version 2207
Table Of Contents
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.141. 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.142. 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:
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.144. 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
.