Announcement Announcement Module
Collapse
No announcement yet.
Getting ROO generated scaffold to work with GWT and GIN. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting ROO generated scaffold to work with GWT and GIN.

    Hi, I'm not sure if this is the right place to post this, but I need help getting GWT components to work inside the ROO generated scaffold.

    In short, I create a new ROO project, eventually run GWT setup and then try to add my own component using the suggested MVP.

    Let's call the component Ror for the sake of the example and strip out the code that's not relevant:

    Code:
    <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:Button ui:field='myButton'>myButton</g:Button>
            <g:Button ui:field='yourButton'>yourButton</g:Button>
        </g:HorizontalPanel>
    </ui:UiBinder>
    Code:
    package com.ig.client.scaffold.ui.widget;
    
    public class RorView extends Composite implements RorPresenter.Display {
    
        interface Binder extends UiBinder<Widget, RorView> {}
        private static Binder BINDER = GWT.create(Binder.class);
    
        @UiField Button myButton;
        @UiField Button yourButton;
    
        private ClickHandler myButtonClickHandler;
        private ClickHandler yourButtonClickHandler;
    
        public RorView(){
            initWidget(BINDER.createAndBindUi(this));
        }
    
        @UiHandler("myButton")
        void onMyButtonClick(ClickEvent event){
            this.myButtonClickHandler.onClick(event);
        }
    
        @UiHandler("yourButton")
        void onYourButtonClick(ClickEvent event){
            this.yourButtonClickHandler.onClick(event);
        }
    
        @Override
        public void setMyButtonClickHandler(ClickHandler buttonClickHandler) {
            this.myButtonClickHandler = buttonClickHandler;
        }
    
        @Override
        public void setYourButtonClickHandler(ClickHandler buttonClickHandler) {
            this.yourButtonClickHandler = buttonClickHandler;
        }
    
    }
    Code:
    public class RorPresenter {
    
    package com.ig.client.scaffold.ui.widget;
        //--------------------------------------------------------------------
        public interface Display extends IsWidget {
            void setMyButtonClickHandler(ClickHandler buttonClickHandler);
            void setYourButtonClickHandler(ClickHandler buttonClickHandler);
        }
        //--------------------------------------------------------------------
        
        private final Display display;
        private final EventBus eventBus;
    
        @Inject
        public RorPresenter(Display display, EventBus eventBus){
            this.display = display;
            this.eventBus = eventBus;
            bind();
        }
    
        private void bind(){
    
            display.setMyButtonClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    Window.alert("FIT");
                }
            });
    
            display.setYourButtonClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    Window.alert("CIT");
                }
            });
        }
    }
    This Ror component is then added onto the default view (ScaffoldDesktopShell.ui.xml) and for it to work, the view and presenter layers need to be binded.

    Inside ScaffoldModule (com.ig.client.scaffold.ioc) I add my binding code ...
    Code:
    public class ScaffoldModule extends AbstractGinModule {
    
    	@Override
    	protected void configure() {
            bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
    		bind(ApplicationRequestFactory.class).toProvider(RequestFactoryProvider.class).in(Singleton.class);
    		bind(PlaceController.class).toProvider(PlaceControllerProvider.class).in(Singleton.class);
    
            bind(RorPresenter.Display.class).to(RorView.class);
    	}
    ...
    ... yet the binding doesn't appear to be working, the myButtonClickHandler and yourButtonClickHandler inside the @UiHandler s are null giving me a null pointer exception when I click on either of the buttons.

    Any idea what might be wrong with the binding code or why it's not working? What I actually want to be doing is injecting an eventBus and let the buttons fire an event on the event bus, but need to get the binding to work first.
Working...
X