Studio Developer Manual / Version 2107
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 7.112. 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 ActionScript.
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.
var note:Note = beanFactory.getRemoteBean('notes/note/1') as Note; note.load(function(loadedNote:Note):void { trace('My note says: ' + loadedNote.getDescription()); });
Example 7.113. Invoke class from ActionScript
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:
<DisplayField> <plugins> <ui:BindPropertyPlugin bindTo="{ValueExpressionFactory.create('description', beanFactory.getRemoteBean('notes/note/1'))}" /> </plugins> </DisplayField>
Example 7.115. Remote bean used inside a component
This example creates a label which contains the description of our note. Usually RemoteBeans
are
always accessed through a ValueExpression
. The ValueExpression
is then responsible for
loading the value out of the RemoteBean
.