views:

56

answers:

1

Our assignment for our java project is to make a tool for kids to make math excercices. One part should be in a swing application, where the teacher can adjust settings to what the kids should make, view their results, etc... The other part is where kids should be able to make excercices on the internet.

Now, so we thought, as we are seeing Spring in Java courses now (just starting to.).Let's make it a Maven project, and reuse the service layer + DAO, and use the same model. That way the desktop app doesn't have to use the Spring framework neccessarely. (So we thought...)

We came to the conclusion that we don't know enough about MVC to pull this off.The service layer always returns the modified object that was saved in the database after executing business logic. Now this doesn't really work with using MVC in swing (or please tell us how to use MVC the right way..), As, as we see it, the controller modifies the data while the view receives an update of the model (via observer). But that object is replaced by a total new one!

Could please someone help us out of this, or give some tips how to fix this? Double linking controller and view doesn't seem a good idea to us at all, so is there a way to fix this, or would you recommend us to go Spring all the way, even if we have yet to learn this and only have roughly 3 months to make this?

+1  A: 

Create a layer of Model class pojos.

Set them from swing or your web app and directly pass it to Service layer[Spring module in your case] and operate on it.

On WebAPp we have scope like request,session, for swing you need to maintain it manually.

org.life.java
I'm not sure if I'm following you here. It seems I forgot to mention, but we already have a layer of Model POJO's.
toomuchcs
@toomuchcs updated probably this is what you looking for
org.life.java
makes more sense, but could you give a small example (not in code) how to do this? Would you think of this as a good approach? Because it sounds like making your own framework
toomuchcs
@toomuchcs I would say make the service code just to return whether the operation done successfully or not or you can throw exception from it. I would recommend update view at view layer only, it should be totally independent of service layer,
org.life.java