How to make right architecture in Web application using Vaadin framework? Please Help!
HI, I am starting to developing web application and decide to use Vaadin + Java EE for reusable business logic. I know that Vaadin has MVP design pattern, but how to make good hierarchy of classes, write all in one MyApplication.java or make own Button classes or make Listeners in one side and UI components in other, and how to combine it with MVC design pattern of Servlet specification.
I am begin开发者_如何学编程ner in developing project from zero, please Help!In Vaadin a good OO approach is to split your UI logic into custom components that implement a single piece of application UI and maximize the re-usability.
Inherit CustomComponent and build the user interface there and add all event handlers there too. Publish only logical API. The same applies to events. For example: The class OrderEditor extends CustomComponent with functions like setOrder(Order) and getOrder(). Where Order is your business class. Builds a UI for manipulating the Order object. Optionally calls saveOrder(Order) in your service API or sends a OrderChanged event to be handled elsewhere.
It has also been argued that CustomComponent is not much different from the Layout classes. That means it shouldn't make a big difference to extend those instead of CustomComponent. However, the main point here is that you are composing logical pieces of UI with logical business API - publishing only minimal amount of Vaadin APIs that let you manipulate the internal implementation of your component.
精彩评论