Monday, February 22, 2010

CALL JAVA REMOTE OBJECT IN FLEX (STEPS)

At the server-side:

1.Create your remote java class, a POJO.

2.Compile your java file and place the .class file in webapps/blazeds/classes

3.Place dependent jar files in blazeds/WEB-INF/lib

4.Edit blazeds/WEB-INF/flex/remoting-config to create a destination mapped to your POJO.

Sample:

<destination id="itemdelegate">

<properties>

<source>com.stockmgr.dataservices.delegates.ItemDelegate</source>

<scope>request</scope>

</properties>

</destination>

At the client-side

5. Define a RemoteObject component to point the created destination at step 4

Sample:

<mx:RemoteObject id="remoteItemDelegate"

showBusyCursor="true" destination="itemdelegate"

result="resultHandler(event)" fault="faultHandler(event)" />


6.Now call the remote method of your POJO with the id declared in step 5 in

action-script just like old times.

Sample:

remoteItemDelegate.getItem(itemID);