Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Updating Multiple Views

Reply
Thread Tools

Updating Multiple Views

 
 
Jason Cavett
Guest
Posts: n/a
 
      02-09-2007
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?

 
Reply With Quote
 
 
 
 
Daniel Pitts
Guest
Posts: n/a
 
      02-09-2007
On Feb 9, 12:41 pm, "Jason Cavett" <(E-Mail Removed)> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advice on interesting reading and updating num. of views/day forobject. edfialk Java 0 05-09-2008 07:03 PM
Updating JTable Atomically - block data changes while updating. news.rcn.com Java 2 12-10-2007 11:49 AM
DataSourceControl with multiple views and data binding order Bill Sexton ASP .Net 1 01-26-2007 01:31 PM
Design pattern for multiple views Ruben Java 3 03-27-2006 07:16 PM
Having One Page Produce Multiple Views Tim Rogers ASP .Net 3 11-10-2003 02:02 PM



Advertisments