Cafe Townsend

A port of the Cafe Townsend Cairngorm example created by Darren Houle. We modified the Cairngorm example to use Mate Framework. 

Run Example

View Source

Download Source

21 responses

  1. I'm a bit confused (and also fairly new to Flex).. Apologies if this isn't a Mate related question..

    In MainEventMap -> LoginEvent.LOGIN where does lastResult originate?

  2. Michael,
    Regarding lastReturn, see:
    Using lastReturn and Using Smart Objects
  3. Hi Laura, I really like what I've learned so far, but am very new to Flex and as3 and Mate. Two questions please ...

    In the Mate version of this example, if we look at the event map for an employee delete, you wrote "assume everything was ok ..." then dispatch an event to the view to it updates. But in a more complex application, my question is, what are the coding options if the delete (or whatever complex operation needs be done to the model data) does not succeed, and the view(s) need to be notified differently according the outcome of the model operation? In other words, how would I introduce some fault related logic into a controller map?

    On the topic of the verbosity of injectors, but still relevant to the different versions of this example app: I notice the Cairngorm example does not use injectors but the same function is achieved via direct view/model data binding. Is the use of PropertyInjectors intended for, or limited to, clearly defining/decoupling data binding mappings or can PropertyInjectors or other Injector inner tags be used to inject data into a view without using binding? More generally speaking I suppose I'm wondering is injectors mostly used for code clarity/readability?
  4. Emmett,
    This is not a good example for that because there is no actual service call made.
    If you want to handle service faults, you would use <faultHandlers>, see the documentation for handling service responses.

    Regarding the benefits of Injectors, I would recommend you to watch the 360Flex presentation where I go through the benefits and drawbacks of each approach, if you have an hour to spare. The short answer is that they help us a lot with decoupling.

    Injectors can be used to set data once, with no binding established between the source and the target, but it depends on the use case.
  5. Hi Laura,

    About Injectors: I shall watch that preso thanks, and you explained a bit for me already.

    Having no service call in this Mate example, is actually why I was wondering how to handle a locally thrown fault after a MethodInvoker. Confusing words by me I suppose. Maybe I am thinking of Mate in the wrong way, but pls let me give two perspectives:
    1) Why should a called method always succeed? Honestly I don't know how complex the called methods are assumed to be in the Mate fashion, so ask this as a real question. Today I learned about the lastReturn value. Assuming called methods might often fail, using any return value for errors instead of exceptions can get very messy if an error type and error info needs to be passed back to the caller. The usual selling point for using exceptions instead.
    2) Conceptually I see no difference between a remote method call throwing an exception or a local method call doing the same thing. Despite me never seeing an example of this yet, upon a UI event in a client/server app, I see no reason why an event map should always consult a remote data model before a local model. eg. The local model could store a current working copy of a server's master model data, and the local model manager decides to make remote calls to the server when required. In such an app (which I want to build) I visualize the event maps for calls to local managers would look very different to those for remote service calls.
  6. Emmett,
    I welcome your questions, but I am the only one that monitors the doc comments here. I suggest that we take this conversation to the forums.
    Also see AsyncMethodInvoker.html">, it may be what you want.
  7. Thanks Laura, AsyncMethodInvoker looks very interesting!
  8. In the code below, there is a bindable on the navigationPath() property, and an event is dispatched when 'updatePath' is called. Doesn't this mean the event is dispatched twice?

    public function get navigationPath():String
    return _navigationPath;

    public function updatePath( path:String ):void
    _navigationPath = path;
    dispatchEvent( new Event( "navigationChange" ) );
  9. I might have seen this wrong.

    Probably, the dispatchEvent() will trigger the binding again. Is this correct?
  10. Hi,

    I really like this implimentation, using the presentation model and such. Why is it that after ever function you added another event dispatched? For example;

    dispatchEvent( new Event("employeesChange") );

    What does this do? What purpose does it serve?

  11. Frank,
    dispatchEvent( new Event( "xxxx" ) ); exists to support the Bindable tag. See:
  12. Thanks Laura,

    As you can tell I'm new to Flex. From what I gathered from your post variable binding will be delayed until the event is dispatched.


  13. Hi,

    I wonder if it's possible to inject a view into a presentation model instead a presentation model to a view. Something similar to what is donde in this Swiz example ( ) where the view is injected into the presenter.

  14. Hi Polaco,
    See this post:
    The key point is that you can pass the view to anything by using event.injectorTarget (ie: as a constructor argument, method argument, property, etc).
  15. Hi Laura,

    I'm trying to use this as a sample for a project that I'm working on. First I set this up to read an xml file local to my system and all works well. However, when I try to read from the database using Coldfusion, I have issues.

    After logging in, the datagrid does populate but when I click on an item in the datagrid, it comes up empty. My debugger shows that the RemoteObject is working okay, but it looks like the injector is failing to populate the detail view. When I click on the row, the debugger shows that it's passing in a null. When I change back to using the xml file however all works okay. Do you have an idea where I can start to fix this? Your help would be appreciated.


    Frank Gonzalez
  16. Hi Frank,
    If it works for you with the xml file, then the injector is not the problem. I'd check that you are correctly setting the data in the manager.

    Please make further questions in the forums.
  17. Thanks Laura,

    I've tried to post on the forums but was unable to both access and register a new account. I was able to solve my dilemma though. However I do have a question concerning this type of application. As coded, the application updates the array of objects loaded in memory. How does one, in particular using the Mate framework, update the database ? Do you have an example that I may use that updates to the database when the user clicks on the submit button? Thanks so much..this is great stuff!!

  18. I'm still hoping to get a response from my last question.

    One would be very much appreciated.

  19. Frank,
    What happens on the server is beyond Flex and Mate, I would recommend you to look at any tutorial on how to handle forms and server-side integration with Flex.
  20. Brand new to Flex, Action Script and Mate. I'm looking over the example, namely Cafe Townsend.

    I'm having a hard time understanding what is going on when you declare [Bindable(Event="validationChange")] in the

    This is done various places in this class. Then near the bottom of the class you have ;

    dispatchEvent( new Event( "validationChange" ) );

    What's this for and what exactly happens? My guess is that when the event is dispatched that all functions directly underneath are executed. Is this correct? If not
    what happens when the event is dispatched and what is the signficance of all the functions directly
    below the [Bindable(Event="clearFields")]?

    Thank so much..

  21. I read up on using the bind metatag. I'm getting a picture of how by using the this tag that variables can be bound, but then what happens in the same class ( when clearFields is dispatched? I see that the function returns "". But to what? I'm confused. Please help.

Comments now closed