Navigator7 and Guice

First, thanks for the addon, John. I have only just got started with it, but it seems to be easy to use, and answer a lot of problems.

I would like to combine use of Navigator7 with Guice for dependency injection - but looking at the notes for
integration, and NavigableApplicationServlet, I am struggling to combine them; I would admit my servlet knowledge is limited, which is not helping.

Any pointers would be greatly appreciated

Hi David,

I have that working. You have to do the following steps:

Extends the NavigableApplicationServlet. You have to do that because Guice need to bound servlets in Singleton scopes, so in order to set the NavigableApplicationServlet as Singleton, extend it and add the @Singleton annotation (It’s just a blank class).

public class NavigatorServlet extends NavigableApplicationServlet { }

In your module, map the above servlet to another url pattern than “/" (as example, you can use: "/app/”). As you can see in the example below, this is needed because you have the “/*” uri patter mapped to the GuiceServlet.

	protected void configureServlets() {
		// = Init. Parameters.
		final Map<String, String> initParams = new HashMap<String, String>();
		// = Configure the Servlet.
		serve("/*").with(GuiceApplicationServlet.class, initParams);
		final Map<String, String> navInitParams = new HashMap<String, String>();
		navInitParams.put("webApplication", "com.yoostar.application.MyWebApplication");
		navInitParams.put("application", "com.yoostar.application.MyWebApplication");
		serve("/app/*").with(NavigatorServlet.class, navInitParams);
		// = Bind our application.

Follow the initial setup of the Navigator 7.

Let me know if its work for you. I have an example if you want it.

Hi Mauro

I missed this reply somehow - but thanks. We did get there in the end, and I would be happy to share that with anyone who reads this, although I think Mauro has already provided a good answer.

I have to say we are finding the combination of Vaadin, the Navigator7 addon and Guice a very productive one