ColdBox Framework Forums Notification: Post to Coldbox with Flex

Title: RE: Coldbox with Flex
Thread: Coldbox with Flex
Forum: Discussions
Conference: ColdBox
User: lmajano Hi Tariq,

The best way to integrate it is via the coldbox proxy object. You
have the option to either create remote objects that extend the proxy or create
one object that extends the proxy and use the event driven model within coldbox.
1) Event Driven Model
If you go this route, you will be basically re-routing
flex or any external GUI application requests to the ColdBox event model. You do
this by calling the process() method and attaching the event name argument plus
any other arguments you would like to pass into the request, just like a
form/url action. The framework then treats the request as any other event
requests, executes the handler and action needed, detects if the event handler
produces any kind of result and then relays back the results to flex. This
approach let's you share event handlers with any gui and you can create
different executions paths by just using: event.isProxyRequest(). This method
determines if you are within a normal MVC html execution or a remote execution.
This let's you decide if you want to produce HTML or return results.

As you
can see, the remote event-driven approach is very flexible and let's you
basically code in coldbox handlers. It let's you use all the methods, plugins,
interceptions you are normally used to in an MVC html call.

Now, from the
flex end, you would need to create a delegate class that can encapsulate these
calls, you basically can say, coldboxDelegate.process(event, argCollection)
This process method, would create a remote object via AS3 to the proxy object
(via remoting) and just call its process() method with the passed in arguments.
2) Remote Proxies

This approach is basically the same as if you where
building remote proxies to a built object model. The difference is that these
proxy objects, extend the coldbox proxy object. This way, you can easily tap
into coldspring/lightwire and get beans to interact with.

You can create a
function called getUsers() that has the following:


That's it. The proxy knows how to get to
the ioc plugin and get your beans.

What are the differences? With remote
proxies, you are just going directly to model objects and getting or saving
data. With the event-driven model, you are actually creating a lifecycle for a
request. The request can have interceptions, security, and implicit events.
Those are the two ways that you can interact with Flex. I would say it all
depends on your requirements and how you would like to architect your
application. I hope this helps out, let me knwo if you have any more questions.