Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MVC with a twist.

Posted on 2006-11-09
4
Medium Priority
?
391 Views
Last Modified: 2013-11-24
Hi all,

Old programmer, getting there with Java, new to GUI.

I want to put together a GUI that handles interrelated models. The model is a Person object in a family tree. The view will initially just be a box with the person's details shown in it, linked with lines to parents, siblings and children. The controller will obviously bind these two together.

I want to allow the user to move from person to person, up to parents, left/right to siblings and down to children, probably with cursor keys.

My problem is this. The view can recognise the user operation, say 'select father'. It must then ask the model (a Person object) to identify which person is its father. But how can that mechanism then indicate which controller or view should be signalled to take focus?

Clearly I could create a Map that lets me find the controller responsible for the parent of the person but this feels like breaking the whole advantage of the MVC pattern. Is there a 'good' way of dealing with this?

Paul
0
Comment
Question by:PaulCaswell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
jaggernat earned 1000 total points
ID: 17910766
View represents the front-end User Interface.
Controller represents the object which gets the values from user interface, calls appropriate classes and forwards a response back to the view.
Model represents the Object which holds the information in the front-end view and passes it over to the controller when controller is invoked

>>>But how can that mechanism then indicate which controller or view should be signalled to take focus?

You would have a single "controller" which would control the entire application.
You would have multiple "views", for parents , children, siblings, ect and you would have their corrosponding objects as Models.

I am not sure if you have followed the MVC architecture correctly.

Some refrences which might help:

http://www.enode.com/x/markup/tutorial/mvc.html
http://cristobal.baray.com/indiana/projects/mvc.html

 

0
 
LVL 16

Author Comment

by:PaulCaswell
ID: 17913241
>>I am not sure if you have followed the MVC architecture correctly.
LOL :-)

Nice links! I'll browse through those later.

So the Model is the object, a Person object in my case. This has the responsibility of HOLDING the data.

The box with text in is the View. This has the rsponsibility of DISPLAYING the data.

Who controls user interaction, the view or the controller?

It the data is interrelated at both the model level and the view level (parent, child, sibling) and the controller distributes UI events to the view, how can the view indicate to the controller that focus should be changed or window should be scrolled for example?

Do you see my quandary? I fully agree that the model must be separated from the view, that would allow me to change the view seamlessly, but how can the view tell the controller to scroll the window if it is independent of the controller?

Paul
0
 
LVL 16

Author Comment

by:PaulCaswell
ID: 17913652
Perhaps I have been confused by some sample code I found. It assigns a controller for every person. Is this unusual or normal?

Paul
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17914920
>>>Who controls user interaction, the view or the controller?

The Controller . Controller is the boss :)

>>>how can the view tell the controller to scroll the window if it is independent of the controller

Each view (in MVC) has a unique "mapping" to the controller...meaning , for instance lets say there are three views
Parentview, Childview, Siblingview. Now all these three views call the controller in three different UNIQUE ways , so the controller knows WHO is making the call(parent, child or sibling).

 


 


0

Featured Post

PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This video teaches viewers about errors in exception handling.
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question