View Full Version : OwnerManagerView - How to Know when is closing?
steve_smith
Oct 22nd, 2004, 02:35 PM
For OwnerManagerView in Petclinic, how you can know when is closing? I want to listen to that event. I notice ViewListener interface in javadoc but no addViewListener() method is in View interface. So how you do it?
Keith Donald
Oct 22nd, 2004, 02:46 PM
Right now there is no way to close views. When we support that, we'll add a close event. There is a dispose event though (fired on system close), and a deactivate event (fired when you switch views).
You can attach a view listener by saying view.getContext().getPage().addVewListener(viewLis tener). That listens to all views managed by the page. Do you want to listen to just a single view's events?
steve_smith
Oct 22nd, 2004, 03:00 PM
There is a dispose event though (fired on system close), and a deactivate event (fired when you switch views).
So I can just overide View.dispose() and put my code there? As for deactivate(), I don't see it in View interface...maybe you not checkin yet?
You can attach a view listener by saying view.getContext().getPage().addVewListener(viewLis tener). That listens to all views managed by the page.
Okay. But what is relationship between View and Page. I mean, who own who?
Do you want to listen to just a single view's events?
Yes. In experiment, I modify OwnerManagerView and add form there for some editing (did not use Dialog). Now I want to save changes when view closes. Is possible?
Keith Donald
Oct 22nd, 2004, 03:06 PM
Editors will be "saveable" not Views, but they don't exist yet. :-)
You may still freely override view.dispose() - it will be called when the application is closed (more specifically, the containing window.) In the future it will be called when the view itself is closed.
The ViewListener has a focusedLost event - that is what I meant by deactivation.
The ApplicationPage manages one or more view instances, instantiated by one or more view descriptors. Only one instance of a particular type of view is allowed per page. A single page area exists per window.
Keith
steve_smith
Oct 22nd, 2004, 03:10 PM
Thank Donald. I overide dispose() and it works perfect. My data saved. Very easy. Probably my design is funny but just my experiment so is okay.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.