I was going to ask another question, but I think that there is an
easier way to determine if the reference style is a problem.
Have you turned binding warnings off in Flex config? If so, turn them
back on. You should get a "changes to property ..." warning.
But the question anyway: How does "ModelLocator" get instantiated or
referenced in the component that contains the datagrid?
The danger is in the form of reference like this:
{mx.core.Application.application.myMember{.
Tracy
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of fowleryj
Sent: Monday, October 17, 2005 12:03 PM
To: [email protected]
Subject: [flexcoders] Re: Problem with repeater and datagrid -- Please
help!
Tracy,
In the mxml file, the bindings look like this:
<mx:DataGrid id="searchResultsDataGrid"
dataProvider="{ModelLocator.searchResults}">
And ModelLocator.searchResults contains the results of a database
query (i.e. ModelLocator.searchResults = event.result in the onResult
of SearchCommand.as).
The relevant parts of ModelLocator.as look like this:
class com.desktop.model.ModelLocator implements
org.nevis.cairngorm.model.ModelLocator
{
public static function initialize() : Void
{
ModelLocator.searchResults = new Object();
}
//----------------------------------------------------------------------
------
public static var searchResults:Object;
}
Thanks, and let me know if there's more detail I can give you.
--- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> How are you binding to the variables? I am not using Cairngorm, so I
> apologize if that should be obvious
> Tracy
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED]
On
> Behalf Of fowleryj
> Sent: Monday, October 17, 2005 10:58 AM
> To: [email protected]
> Subject: [flexcoders] Re: Problem with repeater and datagrid -- Please
> help!
>
> Tracy's comment about binding caught my eye because I've been
> experiencing what seems to be unreliable binding in my application.
> I'm curious as to whether the reason is the issue Tracy mentioned. As
> an example:
>
> From my main page, I'll open a popup window whose ComboBoxes should be
> pre-populated with the results from a database call via a
> RemoteObject. These ComboBoxes are empty, and only populate if I close
> the window and re-open it. The same goes for the DataGrid and Labels
> that will be populated with search results-- they are initially empty,
> but populate once the window is closed and re-opened. I should mention
> that I am using Cairngorm, and the dataProviders for all of these
> components are ModelLocator variables, and thus static.
>
> The way that I have worked around this is to stop using ModelLocator
> variables as dataProviders, which I don't like doing, because I feel
> like I'm deviating from the Cairngorm architecture. Here is what I am
> doing instead:
>
> Whenever an event completes (a "SetSearchResultSelection," for
> example, which will store the object that the user selects of all the
> search results stored in the DataGrid), I fire a "FinishedEvent" from
> within that Command class's execute() method that announces that the
> event has completed. This allows me access to the Command class's
> variables (eventObject.<var_name>, for example) in my ViewHelper's
> handleEvent() method via event.data.<var_name>.
>
> Anytime I use this work-around instead of binding to ModelLocator
> variables, the components populate the first time the window is
> opened. Can anyone offer any insight as to why this is the case?
>
> Thank you.
>
> --- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]>
wrote:
> >
> > In your code, you do not have "two mxml files". It does not matter
> > where the code for a component comes from. When the component gets
> > instantiated, it is "in" the application, and you can reference the
> > parent application as Manish suggests.
> >
> >
> >
> > Be careful with binding. While I am not sure about
parentApplication
> or
> > parentDocument references, I AM sure about the
> > mx.core.Application.application style reference from within a
> component:
> > It will NOT reliably support binding, because of data typing issues.
> If
> > you need to bind to something in the application scope, post, and
I'll
> > suggest some solutions.
> >
> >
> >
> > Tracy
> >
> >
> >
> > ________________________________
> >
> > From: [email protected] [mailto:[EMAIL PROTECTED]
> On
> > Behalf Of Parekh, Shweta - BLS CTR
> > Sent: Friday, October 14, 2005 1:49 PM
> > To: [email protected]
> > Subject: RE: [flexcoders] Problem with repeater and datagrid --
Please
> > help!
> >
> >
> >
> > So then two mxml files will be accessing the same actionscript. In
one
> > mxml, the member is set and the other mxml accesses the member. That
> > might work for me. But can two mxml files access the same
> actionscript?
> >
> >
> >
> > -Shweta
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Mink, Joseph
> > Sent: Friday, October 14, 2005 1:18 PM
> > To: [email protected]
> > Subject: RE: [flexcoders] Problem with repeater and datagrid --
> > Please help!
> >
> > Or you can create a static actionscript class with a private
> > member. Set that member, and then everyone who accesses the static
> > class will get the same value for that static member:
> >
> >
> >
> > class StaticClass
> >
> > {
> >
> > public static var theValue;
> >
> > }
> >
> >
> >
> > ...
> >
> >
> >
> > StaticClass.theValue = something;
> >
> >
> >
> > ...
> >
> >
> >
> > if (StaticClass.theValue == something)
> >
> > ...
> >
> >
> >
> > Does that help?
> >
> >
> >
> >
> > ________________________________
> >
> >
> > From: [email protected]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Manish Jethani
> > Sent: Friday, October 14, 2005 12:27 PM
> > To: [email protected]
> > Subject: Re: [flexcoders] Problem with repeater and datagrid --
> > Please help!
> >
> > On 10/14/05, Parekh, Shweta - BLS CTR <[EMAIL PROTECTED]>
> > wrote:
> >
> > > 1. Are there global variables in Flex so that I can take the
> > result from
> > > remote call in a global variable and then use it anywhere --
> > in my case in
> > > the child component?
> >
> > You can save the result in the application and then refer to it
> > from
> > child components using the expression
> > "parentApplication.myResult"
> > (can even bind to it I guess).
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/