• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MVC pattern for GUI

 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am redoing my GUI design. In order to design MVC for GUI, I have to pass all graphic components in View through Controller to Model,
since Model need them to get user interactive data, for example: in order to get user selected
origin airport item, I have to pass originAirport
JComboBox reference to Model. This seems pressty messy. I am wondering if there is a way to get around it. Thanks.
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The model shouldn't have to know anything about the view. When it's time to book a flight, the controller can ask the view which flight was selected, and then pass that info to the model.
In my particular implementation, the controller gets the selected row from the view, then gets the record number for that row from the table model, then passes the record number (and number of seats) to the model.
 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Robin Underwood:
The model shouldn't have to know anything about the view. When it's time to book a flight, the controller can ask the view which flight was selected, and then pass that info to the model.
In my particular implementation, the controller gets the selected row from the view, then gets the record number for that row from the table model, then passes the record number (and number of seats) to the model.


Thanks, Robin for your reply.
TableModel is an exception here. I am talking about apply MVC to oher parts of GUI: view is the graphic presentation, controller handles events, model handles data.
For example, if we have a JComboBox component for origin airport, we show this box in view, assign listeners in controller, receive and handle data in model. But somehow, in order to get user choice from a list of origin airports, we have to pass the component to the model. This make implementation a bit messy. I am wondering if anyone who passed did the same.
By the way, I am using Mark's MVC scheme here.
 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am also wondering if anybody passed SCJD without using MVC in GUI except TableModel?
I believe its not good to pass references around,
or maybe I just cannot do this thing. Anyway,
I only want a passing score for this. Thanks.
 
Robin Underwood
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think of the model as including both the DataClient and the TableModel.
I don't think you need to implement the MVC pattern to pass.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anyway,
I only want a passing score for this.


Holmes, if there is anything that we can teach to anyone taking this exam is to use it as a learning experience.
Just trying to pass this, is not the purpose of the certification. In order to make this Certifiaction really mean something, then you must try hard to learn from it in all ways. By working at doing your best, and more than just passing, I can guarantee you will be very thankful that you did, and you will be a much better developer for it.
Mark
 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, guys. I aim at doing both. Just time is not on my side now.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah I know time can be an issue. Good Luck and well be here to help.
Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic