Flex: How would you create a popup (with PopupManager) and react when it's closed?
Hi,
I'm new to Robotlegs so my question might be dumb or simple but
I've look around and couldn't find any answer to my specific
needs...
I have a view with a button on it that is supposed to pop a
TitleWindow up (it's an "edit window": you select something on a
list, click edit, and get this window where you can rename the item
you selected). After reading posts and FAQs I decided to do this
with a custom event and mapping a command to it. The event is
fired, the mapping executes the command that adds the popup, the
popup is filled with data bundled in the event's payload... And
that works pretty well!
This TitleWindow has some kind of an OK button in it so I now
wonder how to close the popup when this OK thing is clicked and to
update the selected item (supposed to be renamed). What would be
the right way to do that? Would create another custom event and
another command? And how would you access the popup's data (like
the new name)?
I hope someone out there understands my needs and can help a
bit!
Thanks!
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Jason Dias on 09 Jul, 2010 06:30 PM
Hello,
Yes the popup should dispatch another event to save the data to a model
and/or update the view, you could also close the popup based on this event.
Thanks
2 Posted by Quentin on 12 Jul, 2010 08:26 AM
Yes OK, I can do that...
But my main question is: where and when do we save a reference to the object being edited? In the event, in the popup instance, somewhere else? And how do we access the popup's data? Does the event have to carry all this?
That seems OK to me but I'd like to be sure I'm doing things like they're supposed to be done... Still learning!
3 Posted by Jason Dias on 12 Jul, 2010 08:34 AM
Assuming the object being edited is a VO, then I would pass it along as the
events payload.
4 Posted by Quentin on 12 Jul, 2010 08:55 AM
Yes, but would you pass it all the way through?
What bugs me is that there are a lot of steps between the first action (click to edit) and the last (update selected item)... Here's what it looks like:
I don't really understand how my data (the VO and the new name) can travel all the way through and end up together in the last command...
How do we pass the VO from the Command (step 3) to the popup instance (step 4)? Should I create a variable in it to receive that? That's what I'd do at first but that seems odd... Wouldn't that be redundant? Is there another way to do so?
5 Posted by Jason Dias on 12 Jul, 2010 09:37 AM
The short answer is Yes you would pass it all the way through. Here is a diagram outlining similar flow to what you have described. http://www.robotlegs.org/diagram/
Here is an example
In my view I would create an instance of this event and assign the item I want to install, then this event is dispatched to the mediator, and the mediator passes it along to the event bus.
package com.example.events {
}
I have a command named "InstallItemCommand" which has the UserEvent injected into it, this command also has my Service injected. I pass the item into the service, and the service processes that.
package com.example.remote.requests {
}
Once the service has completed it's operation it creates another UserEvent instance, assigns the item that was installed to the event, and dispatches that into the event bus.
If needed I would have another command mapped to the Installed event here to update the UserModel.
My views mediator is also listening for the installed event, so once received it passes the installed item into the view to be displayed in the installed list.
However it sounds like you might be trying to use RobotLegs MVCS implementation to do low level application logic. You might be better off putting the edit functionality into your view. Then you would only be sending the save through the event bus.
disclaimer:
It's really late here, and I may not be thinking clearly, if I am off please feel free to explain your situation further.
6 Posted by Quentin on 12 Jul, 2010 10:00 AM
You're right this is probably too low-level to be handled this way, it was looking to huge to be good (at least for this purpose)!
I will try to have something simpler, I wanted to use all those events+commands+mediators that are new to me but I guess it's not really worth it here... At least I now understand how all this works!
Thanks for all that, you made things a lot clearer.
Quentin closed this discussion on 12 Jul, 2010 10:01 AM.
Jason Dias re-opened this discussion on 12 Jul, 2010 10:04 AM
7 Posted by Jason Dias on 12 Jul, 2010 10:04 AM
No problem, Glad I could help.
Quentin closed this discussion on 12 Jul, 2010 10:28 AM.