That makes sense. Especially if the view has several bound variables. In that case, model="ModelLocator.getInstance()". At the very least, it would make the code more readable. Thanks for your point of view.
-TH --- In [email protected], "JesterXL" <[EMAIL PROTECTED]> wrote: > > I do it because if I don't, my boss yells at me. Something about > "encapsulation" and "View's shouldn't know about ModelLocator... they are > too tightly coupled that way." This allows a master View to act as an > intermediary controller of sorts, and dictate what view knows about what. > Since our applications are friggin' huge, this allows us to easily share > View's throughout. If we shoved ModelLocator in 'em, they wouldn't be > portable. > > This worked great in Flex 1.5, so you really should not worry about > performance in Flex 2... they've optimized this stuff for us so all the > uber-OOP programmer guys don't shoot themselves in the foot performance > wise. > > ----- Original Message ----- > From: "Tim Hoff" <[EMAIL PROTECTED]> > To: <[email protected]> > Sent: Monday, July 10, 2006 11:53 AM > Subject: [flexcoders] Re: Accessing a datagrid inside a different viewstate > > > Hi Jesse, > > I started using this approach because it was used in the samples. > When I sought to increase the performace of the application, I > noticed a little gain when I bound the source directly to the > DataProvider. By creating an additional [Bindable] ArrayCollection > and an additonal reference in the outer description of the > component, it adds to the resources used and instructions. Do you > think that it makes sense to use the direct binding approach instead? > > Tim > > --- In [email protected], "JesterXL" <jesterxl@> wrote: > > > > If the View's, and all parents have a creationPolicy (in the case > of Containers) to "all", then it will be created. However, you > cannot depend on creation order 100%; you'll end up with a race > condition somehwere, and pull you're hair out. You're best approach > is to utilize a ModelLocator approach where you're sub-view, the > datagrid, is bound to data inside the view. This data is exposed as > a public property that has the bindable tag (can be a getter /setter > [mutator] also). That way, as soon as the view is created, it has > the data it needs. > > > > -- pseduo code -- > > > > // ModelLocator class > > > > [Bindable] > > public var my_array:ArrayCollection; > > > > // main view > > > > import ModelLocator; > > > > <view:MyView someData="{ModelLocator.getInstance().my_array}" /> > > > > // sub view > > > > public var someData:ArrayCollection; > > > > <mx:DataGrid dataProvider="{someData}" /> > > > > Make sense? > > > > > > ----- Original Message ----- > > From: Joe Stramel > > To: [email protected] > > Sent: Monday, July 10, 2006 10:59 AM > > Subject: [flexcoders] Accessing a datagrid inside a different > viewstate > > > > > > I have a custom component that I created and I have added it to > the main application. There is a datagrid inside the custom > component. I call the data in the main app, place it in a public > ArrayCollection and want the datagrid to display the data. My > problem is that the datagrid is in a different viewstate other than > the default view and so I get a null reference error when I try to > populate the datagrid from the main app. Is there a way to force > the component to create itself with the main app even though it is > in a different viewstate? Thank you > > > > > > > > > > -- > 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 > -- 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/

