Hi,

I'm currently implementing an app in Cairngorm 2.1 and I've hit a 
kind of brick wall that wouldn't have existed in 0.99...

I'm led to believe that we should no longer use 
ViewHelper/ViewLocator in V2.1 and instead rely more on data binding 
to control everything... so here's the problem...

I have a treeView. In another mxml file I have a 'selection' screen 
which builds a SQL query up based on things the user does. This is 
then fired off and the results displayed in a table. Don't panic! 
This will all be converted to formal webservices later, so 
the 'inline' SQL will go away - this is just a quick prototype.

But anyway... here's the thing...

In mxml_1 we have the treeview. In mxml_2 we have the selection 
screen and a function which constructs the SQL based on the values 
of fields on the screen. We also have the firing of an event to send 
the constructed query to the db. The grid is bound to an array 
collection which is constructed when the command result is invoked.

One of the selection criteria is the branch of the treeview the user 
is currently on...

So when the user selects another branch on the treeview, what I need 
to happen is the sql construction function should be fired on mxml_2 
which in turn retrieves the new SQL which is then displayed in the 
table.

The problem I have is, how can I cause the function on mxml_2 to 
fire ?

Once upon a time I could have simply used viewLocator to find the 
mxml_2ViewHelper and fired a function on there...

But now... how can this work via databinding ?

I already have an int defined in the AppModelLocator which 
represents the id of the current branch - but you can't add 
a 'change' listener to an int - only ArrayCollections as far as I 
can see. I *could* store this info in an ArrayCollection and have a 
listener on that - but this seems pretty clunky and I'm sure there's 
a much more 'correct' way to go about doing this in Cairngorm.

Another way I can do this is to invoke the function directly on 
mxml_2, from mxml_1. I can do this because mxml_1 is in fact part of 
a viewStack on mxml_1. However, is this the 'correct' way ? This is 
how I'm currently doing it, because at least it works - but I really 
want to build this application as closely to the Cairngorm 'ideal' 
as I possibly can.

The docs on Cairngorm seem to be extremely sparse and none of the 
examples I've seen so far illustrate how this situation should be 
handled.

Can someone please provide me with some guidance as to what's 
the 'best practice' here ?

Many thanks,

Jamie.

Reply via email to