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 3681752
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:43:19+00:00 2026-05-19T03:43:19+00:00

I’m trying to access some objects inside a ui:binder component, but not sure of

  • 0

I’m trying to access some objects inside a ui:binder component, but not sure of how to access the eventBus, requestFactory, etc without writing nasty code that will keep me awake at night (also take note that I’m completely new to JAVA, background is in Perl/Python/PHP).

My ui.xml file:

<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
    xmlns:g='urn:import:com.google.gwt.user.client.ui'
    xmlns:ig='urn:import:com.ig.client.scaffold.ui.widget'>
    <ui:style>
        ...
    </ui:style>
    <g:HorizontalPanel>
        ...
    </g:HorizontalPanel>
</ui:UiBinder>

Injecting the eventBus this way fails with
com.ig.client.scaffold.ui.widget.R has no default (zero args) constructor.

public class R extends Composite {

    interface MyUiBinder extends UiBinder<Widget, R> {}
    private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);

    private final EventBus eventBus;

    @UiField SimplePanel fieldA, ...;

    @Inject
    public R(EventBus eventBus){
        this.eventBus = eventBus;
        initWidget(uiBinder.createAndBindUi(this));
    }
}

So, as per the error message, I create a UIFactory and then I get an error
… ‘{style.entityComponent}’> missing required attribute(s): eventBus Element … (seems like it is trying to find the eventBus in the ui:binder stylesheet.

public class R extends Composite {

    interface MyUiBinder extends UiBinder<Widget, R> {}
    private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);

    private final EventBus eventBus;

    @UiField SimplePanel fieldA, ...;

    public @UiConstructor R(EventBus eventBus){
        this.eventBus = eventBus;
        initWidget(uiBinder.createAndBindUi(this));
    }

    @Inject
    @UiFactory R makeR(){
        return new R(eventBus);
    }
}

From reading and reading and more reading for the past couple of days, I haven’t seen anyone accessing the eventBus, requestFactory and historyController directly in the view binding to the ui:binder widget which led to the conclusion that it’s probably not a best practice
anyway.

Let’s say I have an oject, let’s call it Proxy, proxy contains handleButtonClick which then calls eventBus.doSomething(). How do I link this Proxy object to the ui:binder widget without having to instantiate it or without having to pass it around to every widget?

Is it possible to do GIN injection on an interface and then implement that interface via class R which will then somehow contain the objects I’m looking for?

Any solution that work is welcome, just looking for a sample (that a Java n00b can understand) that will basically allow me to connect my front-end with the rest of the services created by ROO.

Thanks
J

  • 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-19T03:43:19+00:00Added an answer on May 19, 2026 at 3:43 am

    Check out the Model, View, Presenter pattern – it solves
    this problem. Generally all non-display logic should be kept out
    of your views so that 1) the non-display logic can be unit tested without
    running inside a (slow to instantiate) browser and 2) different
    displays can be plugged into the same application without duplicating
    the non-display logic.

    Here’s an MVP example exhibiting the
    behavior you’re looking for (note that the style is slightly
    different than the Activities & Places implementation).

    MyPresenter.java:

    public class MyPresenter {
      public interface Display extends IsWidget {
        void setButtonClickHandler(ClickHandler buttonClickHandler);
      }
    
      private final Display display;
      private final EventBus eventBus;
    
      @Inject
      public MyPresenter(EventBus eventBus,
                         Display display)
      {
        this.display = display;
        this.eventBus = eventBus;
    
        bind();
      }
    
      private void bind() {
        display.setButtonClickHandler(new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            eventBus.fireEvent(new MyButtonClickedEvent());
          }
        });
      }
    
      public void go(HasWidgets container) {
        container.add(display.asWidget());
      }
    }
    

    MyView.ui.xml:

    <ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
      xmlns:g='urn:import:com.google.gwt.user.client.ui'
      xmlns:ig='urn:import:com.ig.client.scaffold.ui.widget'>
    
      <g:Button ui:field="myButton"/>
    </ui:UiBinder>
    

    MyView.java

    public class MyView extends Composite implements MyPresenter.Display {
      interface MyViewUiBinder extends UiBinder<Widget, MyView> {}
      private static MyViewUiBinder uiBinder = GWT.Create(MyViewUiBinder.class);
    
      private ClickHandler buttonClickHandler = null;
    
      public MyView() {
        initWidget(uiBinder.createAndBindUi(this));
      }
    
      @UiHandler("myButton")
      void onButtonClick(ClickEvent event) {
        if (buttonClickHandler != null) {
          buttonClickHandler.onClick(event);
        }
      }
    
      @Override
      public void setButtonClickHandler(ClickHandler buttonClickHandler) {
        this.buttonClickHandler = buttonClickHandler;
      }
    }
    

    And in your GIN module: bind(MyPresenter.Display.class).to(MyView.class);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.