Stuff I am building:


Ted Patrick - Events & Community @ Adobe Systems


Note: This is the personal blog of Ted Patrick. The opinions and statements voiced here are my own.



Using Targets with ASR Remoting

DIGG IT!     0 Comments Published Wednesday, October 01, 2003 at 7:02 AM .

Remoting is limiting if you don't provide a custom target. In most remoting cases, you call a remoting method 'event.foo()' and data is returned to 'event.foo_result(n)'. Ideally you pass a target with your request and that target is used to fire a specific method. Here is a sample:

ASR:

function sqlTargetExecute(o){
//store the passed sql value
var sql = o.get('sql')

// get the dataset from the database
var rds = CF.query("data001",sql)

//create a hashmap > Equivalent to Flash Object
var ret = java.util.HashMap()

//add the target property passed to the hashmap
ret.put("target", o.get('target'))

//add the resultSet to the hashmap
ret.put("data", rds)

//return it to remoting
return ret
}

Client AS:

#include "netservices.as"
conn = netservices.creategatewayconnection()
event = conn.getservice("event.event2010", this)
sqlTargetExecute = function(sql, target){

// build an object to pass to remoting
// I prefer using a single object to allow for reuse across many functions
// This is especially helpful when you nest functions in SSAS
var o = {sql:sql, target:target}
//event is the remoting object
event.sqlTargetExecute (o)
}
sqlTargetExecute_result = function(n){
// fire the result data at the passed target
[n.target](n.data)
}

sqlTargetExecute('select * from donut','_level0.ondonut')
_level0.ondonut = function(n){
trace('OnDonut has the data!')
}

Actually this makes remoting highly reusable on both the server and client side. Typically using this approach, you only need 1-2 SS or CS methods since any object can call remoting and get data sent to any path in the player. This is also ideal for when you use loadMovie to bring in external reports that need to access remoting. The reports are swf files containing display components and simple functions calling remoting methods.

On my designating SQL on the client side, that is a bad practice for public sites. Use with caution, bad Ted, Bad!!!

Cheers,

Ted ;)



0 Responses to “Using Targets with ASR Remoting”

Post a Comment

Where to find me:

Ted on Twitter - @AdobeTed
Ted on Adobe Groups
Ted on LinkedIn
Ted on Facebook
Ted at Adobe


Latest

Lists

Links

Jobs

Flex Jobs
city, state, zip

Archives