Hi
I am sure this is a dumb question, so apologies in advance…
Have followed the Vaadin Guice Integration article, so far so good
class MyServletConfig
{// etc
protected void configureServlets() {
serve("/*").with(GuiceApplicationServlet.class);
bind(Application.class).to(SimpleApp.class).in(ServletScopes.SESSION);
bind(Foo.class).to(FooImpl.class);
// bindConstant().annotatedWith(Names.named("bar")).to("bar");
}
}
public class SimpleApp extends Application {
@Inject protected Foo foo;
@Override
public void init() {
Window mainWindow = new Window(""+foo);
setMainWindow(mainWindow);
}
}
The above works (window title=“foo”)
But when I try to inject outside of this class (uncommenting the bar binding of course),
public class SimpleApp extends Application {
@Inject protected Foo foo;
@Override
public void init() {
Bar bar = new Bar();
Window mainWindow = new Window(""+foo+" "+bar);
setMainWindow(mainWindow);
}
}
public class Bar
{
@Inject @Named("bar") protected String text;
public String toString()
{
return text;
}
}
This doesnt work (window title=“foo null”)
Any suggestions
\Dave Mc