close

Filter

loading table of contents...

Studio Developer Manual / Version 2010

Table Of Contents

7.27.4 Using the EntityController

Before using the 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.107. 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.108. 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:

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

Example 7.109. Output from remote bean


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.110. 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.

Search Results

Table Of Contents