As already suggested: Is it not possible to have a setup() method called
from the creationComplete event that sets the values held in the Model
Locator into the text inputs?  On selecting cancel the window closes and
no data changes.  On saving, the data is wrapped in a VO, courtesy of a
view helper and written to the Model Locator (and anywhere else you wish
to store these preferences).  Would this not work - or is there
something I have missed here?

HTHs
Leon



-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of charged2885
Sent: 02 December 2005 15:47
To: [email protected]
Subject: [flexcoders] Re: PreferencesWindow design pattern

Jester, 

this question is a little off-topic, but on my mind none the less...
Where do you put this 
code:

> prefsWindow = PopUpManager.createPopUp(this, PrefsWindow, true);
> prefsWindow.setFormData(ModelLocator.prefsObject);

I naturally want to put this in my PrefsWindowViewHelper, but it doesn't
seem to work 
when there. What I find is happening is every view that's a titlewindow
ends up adding 
code to my applicationViewHelper. this "smells" i think.

todd


--- In [email protected], "JesterXL" <[EMAIL PROTECTED]> wrote:
>
> That's what I've been deadling with for the past 2 days!
> 
> I won't suggest best practices, I'll just suggest what works as of
1:00pm 
> this afternoon.
> 
> My model is much like yours, on ModelLocator, but it's not actually
written 
> to unless the user hits save or apply.  As such, I create a copy of
the 
> preferences object by passing the true one into a fucntion, which
makes a 
> copy, and uses that as something to bind to.  That way, all my
bindings 
> work, but they only affect the real data if the user hits save.
> 
> Psuedo code:
> 
> prefsWindow = PopUpManager.createPopUp(this, PrefsWindow, true);
> prefsWindow.setFormData(ModelLocator.prefsObject);
> 
> 
> // psudeo code in PrefsWindow
> public var formData:Object;
> 
> public function setFormData(o:Object):Void
> {
>     // could be a specific ValueObject type as well
>     // just DON'T set it to null, or delete it; this'll screw up the 
> bindings
>     formData = new Object();
>     for(var p in o)
>     {
>         formData[p] = o[p];
>     }
> }
> 
> public function getFormData():Object
> {
>     return formData;
> }
> 
> Then, in your main class, just replace your VO on the ModelLocator
with the 
> formData.  For avoiding references, see the earlier threads today
about 
> Object.copy.
> 
> 
> ----- Original Message ----- 
> From: "charged2885" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Thursday, December 01, 2005 4:45 PM
> Subject: [flexcoders] PreferencesWindow design pattern
> 
> 
> Note, this example is mitigated. there are dozens of preferences i
want my 
> users to be
> able to set. Anyways....
> 
> I have a simple preference i want my users to be able to set: 
> showConsoleWindow. I have
> created a simple PreferencesWindow with a CheckBox on it. This
checkbox's 
> selected
> property is bound to
ModelLocator.currentUser.preferences.showConsoleWindow.
> currentUser is a UserVO object as described below:
> 
> class UserVO {
>   preferences:PreferencesVO;
>   username:String;
> }
> 
> class PreferencesVO {
>   showConsoleWindow:Boolean;
> }
> 
> I'd like to offer a cancel button to my PreferencesWindow. however,
since
> showConsoleWindow is bound, this approach won't work. It seems I
should 
> first, create a
> temporary preferences object to bind to. This is where my question
comes in. 
> How do I
> create a copy of my ModelLocator.currentUser.preferences object?
> 
> Or would you implement this functionality differently? Please, I'm new
to 
> flex and I want to
> do this "the right way". Thanks for your time.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> 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



 









------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/I258zB/QnQLAA/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/
 



Reply via email to