Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4081248
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:02:11+00:00 2026-05-20T18:02:11+00:00

I have a new project where I am using GWT-Views like Composite, etc. I

  • 0

I have a new project where I am using GWT-Views like Composite, etc.

I have injected the items in the main menu (like ProductList below) using GinInjector. This works fine!

Somewhere I want to have a reference from a small component to an item from my main menu in order to update it. I try to inject it this way:

public class ProductForm extends Composite {
   ...
   @Inject 
   ProductList list;
   ....

}

But when I use the list I always get null. Whereby, ProductList is defined this way:

public class MyModule extends AbstractGinModule {
   ...
   @Override
   protected void configure() {
      bind(ProductList.class).asEagerSingleton();
      bind(ProductForm.class).asEagerSingleton();
   }
   ...
}

Any idea what I am doing wrong?!

Solution:
I failed to mention that ProductForm is an element of the ProductList using the UIBinder’s @UIField tag, So That injecting it will create a new object rather than the one created using UIBinder.

I had to restructure my code to include presenters and an event bus so that no direct references between views are needed (other than the @UIField attributes).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:02:11+00:00Added an answer on May 20, 2026 at 6:02 pm

    I was working through Gin documentation : I’ll quote it here :

    Gin “Magic”
    Gin tries to make injection painless and remove as much boilerplate from your code as possible. To do that the generated code includes some magic behind the scenes which is explained here.

    Deferred Binding
    One way Gin optimizes code is by automating GWT deferred binding. So if you inject an interface or class1 bound through deferred binding (but not through a Guice/Gin binding), Gin will internally call GWT.create on it and inject the result. One example are GWT messages and constants (used for i18n purposes):

    public interface MyConstants extends Constants {
      String myWords();
    }
    
    public class MyWidget {
    
      @Inject
      public MyWidget(MyConstants myconstants) {
        // The injected constants object will be fully initialized - 
        // GWT.create has been called on it and no further work is necessary.
      }
    }
    

    Note: Gin will not bind the instances created through GWT.create in singleton scope. That should not cause unnecessary overhead though, since deferred binding generators usually implement singleton patterns in their generated code.

    You can see for yourself in this URL : http://code.google.com/p/google-gin/wiki/GinTutorial

    It fails to mention why a singleton cannot be autogenerated by deferred binding and injected.

    You can fix this by handcreating, using GWT.create(YourFactoryInterface.class).getProductList() in the constructor.

    This means for testing puposes, you will need to pull the GWT.create into a seperate method and override it in a subclass and use that for testing like :

    YourFactoryInterface getFactory() {
      return GWT.create(YourFactoryInterface.class)
    }
    

    and

    getFactory().getProductList()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a new project and I'm using the repository pattern, I have
I have produced a new Maven Project from gae-archetype-gwt from within IntelliJ, and everything
I've generated a new Web Application project using GWT 2.0.4. I replace the onModuleLoad()
I have created a new MVC2 project using the ASP.NET MVC2 Web Application, which
I have a new project which simply put, is an attempt to formalize the
My new project is targeting an embedded ARM processor. I have a build system
I have a new ASP.NET MVC project (my first), and I had been running
I've just create a new MVC project, and have made no changes at all,
I am fairly new to MySQL and have a project in which I need
I have the following XML document: <projects> <project> <name>Shockwave</name> <language>Ruby</language> <owner>Brian May</owner> <state>New</state> <startDate>31/10/2008

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.