I try to create one MVC Application with Swing. And I am confused with the implementation and how things should be. What i mean is:
I have the Gui which is the view all the logic send to a class named controller and I have a model where I have model properties.(I have read MVC is like that)
I create some Random codes in view with input of how many codes I want and transfer this with
ActionListener
to a Class Named Controller. The Random codes generated with a button on the controller class in a method . The random codes are generated and then i want to save them on a database. I am confused how to save the generated codes on the database. Should i create a method in the Class Named Controller so that i can save them from there? Or another different class with save update find.......... methods? If Yes then why I have create the Model class with Model properties? And how can I use the Model class. what is only left to understand how to use the Model class if I have to use it or if I just have to have this class so that is there. What is the use of Model class if it's only to be there with the properties and do save some where else? What approach is usually used so that I am ok with MVC pattern? Am I confused? Any help I forget to tell that I use Hibernate. thanks ps. I have also read this http://java.sun.com/products/jfc/tsc/articles/architecture/ but i didn't understand it.public class code(){// this is the Model private int i; public void setter(int i){ this.i=i; } public int getter(){ return i; } public String generateStringInt() { return new BigInteger(190, random).toString(32); } // what ever i want to create with the int i variable i will do it on this class? ///then i will pass it on the controller to sent it on the view //OR save if i want to save it.?Is this way of thinking right? //Or is there any other way to do it ? /// if i have a Button and press it from the View it will generate this method?or // i have to do it else? public String generateStringInt() { return new BigInteger(190, random).toString(32); } } //then if i want to save i can just do it like //session.save(object) or is there any other way?
is it better now ? Thanks