{"id":15069814,"url":"https://github.com/mvp4g/mvp4g2","last_synced_at":"2025-04-10T17:36:57.583Z","repository":{"id":57721683,"uuid":"46654747","full_name":"mvp4g/mvp4g2","owner":"mvp4g","description":"Model, View, Presenter with Event Bus \u0026 Place-Managment for GWT based on APT \u0026 Elemental 2. (J2CL / GWT 3 ready!)","archived":false,"fork":false,"pushed_at":"2019-06-17T09:04:47.000Z","size":24386,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-24T15:11:22.608Z","etag":null,"topics":["client-side","eventbus","gwt","java-8","mvp","mvp4g","mvp4g2","places"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mvp4g.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-22T09:55:03.000Z","updated_at":"2025-01-09T15:41:44.000Z","dependencies_parsed_at":"2022-09-26T21:50:22.911Z","dependency_job_id":null,"html_url":"https://github.com/mvp4g/mvp4g2","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvp4g%2Fmvp4g2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvp4g%2Fmvp4g2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvp4g%2Fmvp4g2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvp4g%2Fmvp4g2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvp4g","download_url":"https://codeload.github.com/mvp4g/mvp4g2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248262043,"owners_count":21074236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client-side","eventbus","gwt","java-8","mvp","mvp4g","mvp4g2","places"],"created_at":"2024-09-25T01:44:49.897Z","updated_at":"2025-04-10T17:36:57.560Z","avatar_url":"https://github.com/mvp4g.png","language":"Java","funding_links":[],"categories":["Router"],"sub_categories":[],"readme":"\u003ca title=\"Gitter\" href=\"https://gitter.im/mvp4g/mvp4g\"\u003e\u003cimg src=\"https://badges.gitter.im/Join%20Chat.svg\"\u003e\u003c/a\u003e\n\n\n\n# MVP4G 2\n\n## Preface\nWith the next version of GWT (GWT 3) and the new J2CL transpiller, there will be major changes in the GWT developmemt. For example: JSNI and generators, besides other things, will be gone. Removing generators will cause the current implementation of mvp4g to stop working.\n\nTo prepare MVP4G for GWT 3, the GWT generator has to be replaced by an annotation processor and most of the dependencies of MVP4G have to be removed.\n\nSo, we started a new project, called MVP4G2 and rewrite MVP4G from scratch. MVP4G2 will work with GWT 2 + 3 and will bring major changes. In opposite to the first version of MVP4G, MVP4G2 will not use generators, JSNI or the widget system. Instead it will use Elemental 2 (only for the history implementation) and APT.\n\nMoving to APT will cause changes, related to the options offered by APT. Using the ideas of MVP4G, MVP4G 2 will try to take as much as possible of the principles and features to the next version.\n\nKeep in mind, MVP4G2 helps you to structure your application. It does not offer a widget system nor does it force you to use a particular one. MVP4G2 will work with native GWT widgets, GXT, Elemental (1 + 2), Elemeto, etc.\n\nAt the moment most of the features of mvp4g, which can be used with APT, are implemented (except the multi module feature). A complete list of the things already added in MVP4G2 can be found [here](https://github.com/mvp4g/mvp4g2/wiki/Comparision:-Mvp4g-vs.-Mvp4g2).\n\nThere are a lot of esamples. You can take a look at the mvp4g2 example, that uses APT instead of generators: [https://github.com/mvp4g/mvp4g2-examples](https://github.com/mvp4g/mvp4g2-examples)\n\n## J2CL / GWT3\nMVP4G2 has **no** dependency to gwt-user! This means, MVP4G2 is ready to use with J2CL / GWT 3.  \n\n## Note \nIn case you are thinking about creating a new project based on mvp4g2, you should take a look at [Nalu](https://github.com/NaluKit/nalu) first.\n\n## Project Generator\nTo speed up creating a MVP4G2 project, you can use the [MVP4G2 Boot Starter Project Generator](http://www.mvp4g.org/gwt-boot-starter-mvp4g2/GwtBootStarterMvp4g2.html) (which is also based on MVP4G2). The project generator will generate a Maven project, which can be imported to your preferred IDE and is ready to use. Run **mvn:devmode:** to start the generated project. \n\nHere you find some notes about the project generator: [Mvp4g2 Project Generator](https://github.com/mvp4g/gwt-boot-starter-mvp4g2).\n\n## MVP4G2\nGWT is a very powerful framework that allows you to build efficient applications, especially if you follow the best practices described by Ray Ryan at Google IO 2009:\n\n- Stateless Services\n- Dependency Injection\n- Event Bus\n- Model View Presenter\n- Place Service\n\n(see [https://www.youtube.com/watch?v=PDuhR18-EdM for the video](https://www.youtube.com/watch?v=PDuhR18-EdM) or [http://extgwt-mvp4g-gae.blogspot.com/2009/10/gwt-app-architecture-best-practices.html](http://extgwt-mvp4g-gae.blogspot.com/2009/10/gwt-app-architecture-best-practices.html) for the text, thanks to Araik Minosian.)\nHowever, following these best practices is not always easy and you can end up with a project with a lot of boilerplate code that is hard to manage.\n\nOn the other hand the native GWT implementation has some drawbacks.\n\n- the navigation confirmation does not allow a server call to check if a side is vaild\n- Place management can be hard for complex UI\n\nThat's why Mvp4g offers a solution following these best practices\n\n - Event Bus\n - Model View Presenter\n - Place Service\n - synchronous confirmation\n - event based place manangement\n\n using simple mechanisms that only need a few lines of code and a few annotations.\n\nAnd, keep in mind, mvp4g2 has not dependecy to GWT, therefore it does not know the Element- or Widget-classes. To keep the framwork free of stuff to handle browser elements, these things are part of the developer job. You can use mvp4g2 with any widget framework you like. It will work with native GWT \u003e= 2.8.0, GXT, Elemental 1+2, Elemento or any other widget library. And, from the thinks we know today, it will work with J2CL/GWT 3!\n\n**Important Note:** MVP4G2 requires Java 8!\n\nThis is all you need to create an event bus with four events in mvp4g2:\n```\n@EventBus(shellPresenter = ShellPresenter.class) \npublic interface CompanyEventBus\n    extends EventBus {     \n         \n        @Event        \n        public void goToEdit(CompanyBean company);          \n        \n        @Event        \n        public void goToDisplay(CompanyBean company);          \n        \n        @Event         \n        public void createCompany(CompanyBean newBean);          \n        \n        @Event         \n        public void deleteCompany(CompanyBean newBean); \n        \n}\n```\nAll you have to do to handle an event in your presenter / handler, is:\n* create a method annotated with @EventHandler\n* make sure that the method name looks like this: 'on' + [eventName with first letter capitalize]\n* use the same signature\n\nFor example, to handle the ```goToEdit(CompanyBean company)``` event, use this code inside the handler / presenter:\n```\n       @EventHandler\n       public void onGoToEdit(CompanyBean company) {\n           .... \n       }\n```\nand to handle the ```deleteCompany(CompanyBean newBean)``` just create a method with this code:\n```\n       @EventHandler\n       public void onDeleteCompany(CompanyBean company) {\n           .... \n       }\n```\nTo fire an event, call ```eventBus.goToDisplay(myCompanyBean);``` inside you presenter or handler.\n\nMvp4g2 makes sure, that all handlers / presenters, that implemet a event handler for the goToDisplay-event will be called!\n\nOf course, the old style of binding a presenter / handler to an event still works!\nUsing the old style of binding an event to handlers, all you need to do is to create an event bus and use the handlers-attribute inside the @Event-annotation.\nHere an example of a event bus with four events:\n```\n@EventBus(shellPresenter = ShellPresenter.class) \npublic interface CompanyEventBus\n    extends EventBus {     \n         \n         @Event(handlers = CompanyEditPresenter.class)        \n         public void goToEdit(CompanyBean company);          \n         \n         @Event(handlers = CompanyDisplayPresenter.class)         \n         public void goToDisplay(CompanyBean company);          \n         \n         @Event(handlers = { CompanyListPresenter.class, CompanyDisplayPresenter.class })         \n         public void companyCreated(CompanyBean newBean);          \n         \n         @Event(handlers = CompanyListPresenter.class)         \n         public void companyDeleted(CompanyBean newBean);\n          \n}\n```\nTo handle the ```goToEdit(CompanyBean company)``` event, just create a method in the handler / presenter that looks like this:\n```\n       public void onGoToEdit(CompanyBean company) {\n           .... \n       }\n```\n\n#### Here are some of the key features of mvp4g2\nEventbus:\n- create an event bus using a few annotations and one centralized interface where you can easily manage your events\n- control your event flow thanks to event filtering\n- see what your application does thanks to event logging\n- send events only to presenters / handlers that already handled a event thanks to passive event feature\n- activate and deactivate presenters and handlers thanks to the activate- and deactivate feature\n- have the same control of user's navigation as the GWT Activities/Place architecture thanks to navigation event feature\n\nMVP:\n- create a presenter and inject a view with one annotation\n- support for multiple instances of the same presenter\n- easily implement the Reverse MVP (or View Delegate) pattern thanks to Reverse View feature (MVP4G2 requires the use of the view delegate pattern)\n- easily control your presenter thanks to onBeforeEvent\n- add an event handling method to the event bus with one annotation\n\nHistory Management/Place Service:\n- convert any event to history token thanks to a simple history converters mechanism\n\nNot only does Mvp4g2 help you follow the best practices, it also provides mechanisms to build fast applications:\n- support for lazy loading: build your presenters/views only when you need them.\n- Useless presenters/views are automatically removed.\n\nTo understand how the framework works, you can look at the documentation, the [tutorials](https://github.com/mvp4g/mvp4g2/wiki/1.-Tutorials-and-Examples), the [examples](https://github.com/mvp4g/mvp4g2-examples) or the [mvp4g blog](http://mvp4g.blogspot.de/).\n\n\n\nMvp4g has been successfully used on several commercial projects im the past, [take a look at a few of them](https://github.com/mvp4g/mvp4g/wiki/1.-Tutorials-and-Examples). You can also read and post feedback here: [Mvp4g forum](https://groups.google.com/forum/#!forum/mvp4g).\n\nTo communicate with the developers of MVP4G2 directly feel free to use the [MVP4G Gitter room](https://gitter.im/mvp4g/mvp4g).\n\nAny comments or ideas to improve the framework are more than welcome. If you want to help us to improve and contribute to this project, feel free to do so.\n\nTo ensure quality, library code is covered by JUnit tests.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvp4g%2Fmvp4g2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvp4g%2Fmvp4g2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvp4g%2Fmvp4g2/lists"}