我们的 Java 项目的任务是制作一个供孩子们进行数学练习的工具。其中一部分应该是秋千应用程序,老师可以根据孩子们应该做的事情调整设置,查看他们的结果等等......
另一部分是孩子们应该能够在互联网上进行练习。
现在,我们就这样想了,正如我们现在在 Java 课程中看到 Spring 一样(刚刚开始)。让我们将其设为 Maven 项目,并重用服务层 + DAO,并使用相同的模型。这样桌面应用程序就不必使用 Spring 框架。 (所以我们认为......)
我们得出的结论是,我们对 MVC 的了解不够,无法实现这一目标。服务层总是返回执行业务逻辑后保存在数据库中的修改后的对象。现在,这对于在 swing 中使用 MVC 并不起作用(或者请告诉我们如何以正确的方式使用 MVC..),正如我们所看到的,控制器在视图接收模型更新时修改数据(通过观察者)。但那个物体被一个全新的物体取代了!
请有人帮助我们解决这个问题,或者提供一些如何解决这个问题的提示?双链接控制器和视图对我们来说根本不是一个好主意,所以有没有办法解决这个问题,或者你会建议我们一路走Spring,即使我们还没有学习这一点并且只粗略地了解了这一点3个月做这个?
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)
创建一层 Model 类 pojo。
从 swing 或您的 Web 应用程序设置它们,并将其直接传递到服务层 [您的案例中的 Spring 模块] 并对其进行操作。
在 WebApp 上,我们有请求、会话等范围,对于 swing,您需要手动维护它。
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.