Re: event handling

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri May 07 2004 - 05:33:57 EDT

  • Next message: Claudio Rosati: "RE: event handling"

    Hi Claudio,

    One thing to check is that your listener is retained elsewhere in your
    Java code. EventManager keeps a weak reference to subjects and listeners
    to avoid memory leaks, and it is a user responsibility to retain them in
    the application. In this respect EventManager is different from say Swing
    even sources.

    If this doesn't help, I'll need to try out your code when I come home next
    week.

    Andrus

    > Hello all,
    >
    > I've tried Cayenne with JavaGroups. I've a problem.
    >
    > I launch the same application on two PC. I've a GUI that show the
    > properties of a Cayenne object. I modify the object on the first
    > application and, after a manual update of the GUI (i.e. a repaint of the
    > propertes of a previously loaded - and displayed - instance of the
    > Cayenne object) I see the modified values.
    >
    > Now I would like to use events in order to perform an automatic GUI
    > update when the same object is modified elsewhere. I have used the
    > following code:
    >
    > dataContext = DataContext.createDataContext();
    >
    > DataRowStore cache = dataContext.getObjectStore().getDataRowCache();
    > SnapshotEventListener customListener = new SnapshotEventListener() {
    > public void snapshotsChanged ( SnapshotEvent event ) {
    > System.out.println("*** Something ghanged! ***");
    > }
    > };
    >
    > EventManager.getDefaultManager().addListener(
    > customListener,
    > "snapshotsChanged",
    > SnapshotEvent.class,
    > cache.getSnapshotEventSubject(),
    > cache
    > );
    >
    > ... read the object and display it on the GUI ...
    >
    >
    >
    > What happened is: nothing! The listener is never called.
    >
    > Now the questions:
    >
    > 1. Why? What I am missing?
    > 2. In which thread the snapshotsChanged method is called? The same of
    > GUI (Swing/AWT) events?
    >
    > Thanks in advance.
    >
    > Claudio
    >



    This archive was generated by hypermail 2.0.0 : Fri May 07 2004 - 05:33:57 EDT