Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #900

Re: Updating Multiple Vie

From "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this>
Subject Re: Updating Multiple Vie
Message-ID <1171063403.940179.195960@v45g2000cwv.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
References <1171053677.431316.175880@q2g2000cwa.googlegroups.com>
Date 2011-04-27 15:30 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui,comp.l
On Feb 9, 12:41 pm, "Jason Cavett" <jason.cav...@gmail.com> wrote:
> Here's my problem...
>
> I have one Model.
> I can have multiple views to that model (depending on how the user
> wants to see the information).
>
> Problem: The user can have multiple views to the same model open at
> the same time.  If the user changes data in one view (which will
> update the model), I want it to reflect in the other view(s).  I
> originally tried this by notifying all observers of the model (which
> includes the original view that was just edited) and repopulating the
> fields of the views.  But, when I fire off the notification, I get
> this exception:
>
> Exception in thread "AWT-EventQueue-0 java.lang.IllegalStateException:
> Attempt to mutate in notification
>
> ...whenever I edit a TextField or anything else with a
> DocumentListener.
>
> I sorta understand why this is happening (writeLock() and not being
> able to modify while I'm notifying) but I am very confused on how to
> fix it.  Can anybody give any suggestions?

First, this is more on-topic at comp.lang.java.gui.
Second, your views shouldn't modify any part of the model based while
responding to a change in the model.

If you should implement a single model that represents all
interconnected aspects of your business domain, and have all of your
components able to read values from the model.

Having a model observer modify the model runs the risk of infinit
recursion or infinit loops.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Updating Multiple Vie "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000
  Re: Updating Multiple Vie "Jason Cavett" <jason.cavett@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000
    Re: Updating Multiple Vie "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:30 +0000

csiph-web