My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
HowtoIntegrateMvp4g  
How to integrate Mvp4g to your project
Featured
Updated Feb 19, 2012 by plcoir...@gmail.com

Introduction

To integrate Mvp4g into your project, the following steps need to be done

  1. Add needed library to your project or add a Maven dependency
  2. Modify your GWT configuration file (*.gwt.xml)
  3. Set your entry point
  4. Create your event bus, presenters, views...
  5. Set up Mvp4g APT (optional)

Library

Add the following libraries to your project:

You can also download the Mvp4g examples and copy the libraries inside the lib directory

Maven Dependency

Add the maven dependency:

<dependency>
	<groupId>com.googlecode.mvp4g</groupId>
	<artifactId>mvp4g</artifactId>
	<version>1.3.1</version>
</dependency>

Mvp4g is available on Maven central.

GWT configuration file

Insert Mvp4g module into your project:

<inherits name='com.mvp4g.Mvp4gModule'/>

Set an entry point

Using RootPanel

If you want to display your project inside a RootPanel, you can:

  • either choose the Mvp4g Entry Point as an entry-point by modifying your GWT configuration file:
  • <entry-point class='com.mvp4g.client.Mvp4gEntryPoint'/>
  • or have the following lines (and only the following lines) in your entry-point
  • Mvp4gModule module = (Mvp4gModule)GWT.create( Mvp4gModule.class );
    module.createAndStartModule();
    RootPanel.get().add( (Widget)module.getStartView() );

Using RootLayoutPanel

If you want to display your project inside a RootLayoutPanel (needed incase you use Layout), you need the following lines (and only the following lines) in your entry-point :

Mvp4gModule module = (Mvp4gModule)GWT.create( Mvp4gModule.class );
module.createAndStartModule();
RootLayoutPanel.get().add( (Widget)module.getStartView() );

Event bus, presenters, views...

Now that you have configured your project to use Mvp4g, you can look at the rest of the documentation to create the different elements you need.

Mvp4g APT

By default, all the errors due to wrong Mvp4g configuration are detected when you start the GWT compilation or the GWT dev mode. Thanks to the APT, you can detect most of these errors directly in the IDE. You can check Mvp4g APT for more information.

Comment by maxim.ze...@gmail.com, Oct 13, 2009

btw, why don't you provide 'ant' or 'maven' script for examples building?

Comment by project member plcoir...@gmail.com, Oct 16, 2009

I guess I could easily provide ant files for the examples. I created  issue 11  in order to add them in next delivery.

Comment by sergicon...@gmail.com, Jan 11, 2010

Hi! One question. It's posible add two or more packcages where are located presenters, views or servers??

Thanks!

Comment by project member plcoir...@gmail.com, Jan 11, 2010

You can have severals tag <presenters package="..." /> so you can enter several values for packages but it may make your configuration file messy (a part of this discusion is about this problem: http://groups.google.com/group/mvp4g/browse_thread/thread/7baeff82d0b7c480/2193edb0191b1ef8?lnk=gst&q=configuration#2193edb0191b1ef8).

In 1.0.0 version, there is no other way to do it. You can also define your class elements relatively to package attribute:

<presenters package="com.mvp4g.example">

<presenter class=".module1.presenter.Presenter" /> <presenter class=".module2.presenter.Presenter" /> <presenter class=".module3.presenter.Presenter" />
</presenters>

In 1.1.0 snapshot, you can use annotations which is much easier to configure than xml file or you can also divide your application into modules and have one configuration file for each module.

Comment by sergicon...@gmail.com, Jan 12, 2010

Thank you very much.

Comment by kondotine, Aug 16, 2010

Awesome works Pierre! your framework is great !!

Comment by benjamin.barbier.59, Mar 7, 2011

Info: tu use maven, add this in your pom.xml :

<repositories>
  <repository>
    <id>MVP4G</id>
    <name>MVP4G repository.</name>
    <url>http://mvp4g.googlecode.com/svn/maven2/releases</url>         
  </repository>
</repositories>
Comment by project member plcoir...@gmail.com, Mar 15, 2011

Mvp4g 1.3.0/1.3.1 are now available on maven central

Comment by tkatchs...@gmail.com, Apr 11, 2011

Hi There could I make a suggestion about following line...

RootPanel?.get().add( (Widget)module.getStartView() );

to be changed to

RootPanel?.get().add( ((IsWidget?)module.getStartView()).asWidget() );

This way the view itself can use composition or inheritance a bit more flexibility...

Comment by steve.zi...@bettercloud.com, Mar 8, 2012

Thanks for the great framework! Any chance 1.4.0 will be added to maven central?

Comment by project member plcoir...@gmail.com, Mar 9, 2012

I hope to have it on maven central by the end of this month.


Sign in to add a comment
Powered by Google Project Hosting