Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

Updating Multiple Views

Thread view: 
Jason Cavett - 09 Feb 2007 20:41 GMT
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?
Daniel Pitts - 09 Feb 2007 23:23 GMT
> Here's my problem...
>
[quoted text clipped - 19 lines]
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.