- 3,735,154 Users
- 2,247,120 Discussions
- 7,857,747 Comments
- 381K All Categories
- 2.1K Data
- 203 Big Data Appliance
- 1.9K Data Science
- 446.2K Databases
- 220.5K General Database Discussions
- 23 Multilingual Engine
- 507 MySQL Community Space
- 459 NoSQL Database
- 7.7K Oracle Database Express Edition (XE)
- 2.8K ORDS, SODA & JSON in the Database
- 438 SQLcl
- 3.9K SQL Developer Data Modeler
- 185.4K SQL & PL/SQL
- 20.8K SQL Developer
- 291.4K Development
- 6 Developer Projects
- 117 Programming Languages
- 288.1K Development Tools
- 96 DevOps
- 3K QA/Testing
- 645.2K Java
- 18 Java Learning Subscription
- 36.9K Database Connectivity
- 149 Java Community Process
- 104 Java 25
- 22.1K Java APIs
- 137.7K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 12 Java Essentials
- 139 Java 8 Questions
- 85.9K Java Programming
- 79 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.2K Java SE
- 13.8K Java Security
- 195 Java User Groups
- 181 LiveLabs
- 34 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 165 Deutsche Oracle Community
- 1.2K Español
- 1.9K Japanese
- 225 Portuguese
How to completely separate Model from View in MVC? Or How the Model Updates the View?
I'm Building a Swing Application but i'm having a problem trying to implement MVC,
I searched a lot about this but all explanations or examples i found has to be missing something.
Based on my understanding in an MVC environment the View and the Model have to be completely decoupled ... meaning the we shouldn't import any classes from the Model into the View or vice versa (Correct?)
And i did this already but in some situations i find my self in a position that i must import a class from the model into the View.
For example ... The app i'm building is a POS application.
So in the View i have a table ... this table displays the items been sold.
Now when user choose an item he calls a method in the Controller which in turn calls a method in the model to query the database for that item gets all the information and then add it to a List<Product>.
The view then calls another method in the Controller to get that List and update the JTable with the new list (to show the items on the View JTable).
But here is my problem the List ... to show the item's info on the JTable a List is not sufficient instead i need a List<Product> to be able to get each product column value.
And there you go now i must import Product which is POJO i created in the model that holds the product attributes.
I hope i explained it well ... i wish i could support this question with my codes but i'm pretty sure it'll confuse you more than it'll help ... I'm working on it.
Note: I know how to reach the Model From the View (Using Controller methods) ... But what i really can't understand is how the Model updates the view.
Thank you for your time