Results 1 to 6 of 6
Thread: MVC question
- 07-08-2011, 10:33 AM #1
Member
- Join Date
- Aug 2010
- Location
- Leuven, Belgium
- Posts
- 79
- Rep Power
- 0
MVC question
Hi,
I have a model that extends Observable and a view that implements Observer.
With a Controller that checks the mouseclicks.
But when the user doubleclicks on the view another view has to be updated using the model.
So that means that the controller needs to extends Observable as well.
Is this common practice or is there another way.
thx
- 07-08-2011, 10:39 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-08-2011, 10:53 AM #3
Member
- Join Date
- Aug 2010
- Location
- Leuven, Belgium
- Posts
- 79
- Rep Power
- 0
The model is data from a file and the view is a table displaying the data.
When the user doubleclicks on a column from the table, the content from the column is displayed as a graph on another view.
It is the controller that receives the doubleclick so he has to notify the second view that somebody selected a column to display.
Thats why the controller (in my opinion) has to be an observer for the second view.
- 07-08-2011, 11:42 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
No, think of it this way: V ---> C <--- M where the View and the Model are the Observables and the Controller is an Observer (Listener most of the time). A Controller 'communicates' directly with Views and Models while the Views and Models simply 'signal' their changes to the Controller (through the Observable/Observer pattern or through the registered Listener mechanism). The Controller always is just an Observer.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 07-08-2011, 12:19 PM #5
Member
- Join Date
- Aug 2010
- Location
- Leuven, Belgium
- Posts
- 79
- Rep Power
- 0
Hi Jos,
Ok that answers my question.
Many thanks.
Dipke
- 07-08-2011, 12:54 PM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
Just FYI: my V ---> C <--- M model doesn't make the V and M talk to each other; the 'old' MVC model did allow it, but it is often considered 'cleaner' to make all 'communication' go through the middle C component. It makes the Controller more like a 'Mediator' (another design pattern).
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
What exactly is this question asking?
By kmjt in forum New To JavaReplies: 2Last Post: 01-27-2011, 04:01 PM -
Question concerning question marks and colons
By jim01 in forum New To JavaReplies: 17Last Post: 01-14-2011, 12:05 AM -
Question mark colon operator question
By orchid in forum Advanced JavaReplies: 9Last Post: 12-19-2010, 08:49 AM -
MVC question
By Tom_ in forum Advanced JavaReplies: 1Last Post: 08-12-2010, 12:01 PM -
help question
By 99w210 in forum NetBeansReplies: 0Last Post: 03-08-2010, 05:23 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks