GWTP ViewWithUiHandlers: uiHandlers are not set. Did you call getUiHandlers() from your view's constructor? in PresenterWidget - gwt

I have problem that I do not understand. I think I've done what I supposed to do, but it dosnt work.
I cannot executed presenter methods from view using ui handlers. Error says that I did not set ui handlers but I did:
#Inject
FileUploaderPresenter(EventBus eventBus, MyView view, PlaceManager placeManager) {
super(eventBus, view);
getView().setUiHandlers(this);
this.placeManager = placeManager;
}
and
public FileUploaderView() {
super();
this.getUiHandlers();
this.initWidget(uploader);
}
But I am getting an error:
com.gwtplatform.mvp.client.ViewWithUiHandlers
SEVERE: uiHandlers are not set. Did you call getUiHandlers() from your view's constructor?
For sure I will post all my classes related:
public class FileUploaderModule extends AbstractPresenterModule {
#Override
protected void configure() {
bindSingletonPresenterWidget(FileUploaderPresenter.class, FileUploaderPresenter.MyView.class, FileUploaderView.class);
}
}
public class FileUploaderPresenter extends PresenterWidget<FileUploaderPresenter.MyView> implements FileUploaderUiHandlers {
interface MyView extends View, HasUiHandlers<FileUploaderUiHandlers> {
}
PlaceManager placeManager;
#Inject
FileUploaderPresenter(EventBus eventBus, MyView view, PlaceManager placeManager) {
super(eventBus, view);
getView().setUiHandlers(this);
this.placeManager = placeManager;
}
#Override
protected void onBind() {
super.onBind();
}
#Override
public void onOk() {
Routing.Redirect.toLoginPage(placeManager);
}
#Override
public void onUnauthorized() {
Routing.Redirect.toLoginPage(placeManager);
}
}
interface FileUploaderUiHandlers extends UiHandlers {
void onUnauthorized();
void onOk();
}
public class FileUploaderView extends ViewWithUiHandlers<FileUploaderUiHandlers> implements FileUploaderPresenter.MyView {
MaterialFileUploader uploader = new MaterialFileUploader();
public FileUploaderView() {
super();
this.getUiHandlers();
this.initWidget(uploader);
MaterialUploadLabel label = new MaterialUploadLabel();
label.setTitle("Put Your's files here and here");
label.setDescription("Some description here");
uploader.add(label);
uploader.setMaxFileSize(10000000);
uploader.setUrl(ServiceRouting.FULL_SERVICE + ServiceRouting.FileService.upload);
addHandlers();
}
private void addHandlers() {
uploader.addUnauthorizedHandler(new UnauthorizedHandler<UploadFile>() {
#Override
public void onUnauthorized(UnauthorizedEvent<UploadFile> event) {
GWT.log("UnauthorizedEvent (" + event.getTarget().getName() + " | " + event.getResponse().getCode() + " | " + event.getResponse().getMessage() + "|" + event.getResponse().getBody()
+ ")");
MaterialToast.fireToast("Redirect to login page");
getUiHandlers().onUnauthorized();
}
});
}
I instantialize this widget with: FileUploaderView()
Is this error happens, cause I don't use uiBinder?
This is my first PresenterWidget. Maybe it should be done differently from standard Presenter. Any help appreciated.

Alright, I've figure it out on my own.
The problem is that This Presenter/View pair is a widget. So it should be instantialize with slot mechanism of gwtp. And to do this we use bind method with Presenter class parameter (not view like I was doing).
#Inject UploaderPresenter fileUploaderPresenter;
#Override
protected void onBind() {
super.onBind();
setInSlot(SLOT_FILE_UPLOAD, fileUploaderPresenter);
}
Here is documentation:
http://dev.arcbees.com/gwtp/tutorials/tutorial-part2.html
sections:
Binding the PresenterWidget
Set in slot
Bind Slot
http://dev.arcbees.com/gwtp/core/presenters/

Ok, just let's trace the steps from your code:
This is the constructor of your presenter. MyView view injected here WAS ALREADY CREATED here to be passed to your constructor.
#Inject
FileUploaderPresenter(EventBus eventBus, MyView view, PlaceManager placeManager) {
super(eventBus, view);
getView().setUiHandlers(this)
which means
public FileUploaderView() {
super();
this.getUiHandlers();
this.initWidget(uploader);
}
is called BEFORE presenter contructor. So you call this.getUiHandlers() before you set them in Presenter's constructor.
Move the call to some kind of #UiHandler

Related

GWTP displays default place on application start even if url say to go to other place

I wonder how to change gwtp behaviour.
When I start gwt app (enter app url in browser) it always displays for me default place. But when I enter url as follow: localhost/app#settings gwtp should open place Settings, but unfortunatelly it displays me Default place.
Url in web browser address points to Settings but the view is from default place.
I would like to gwtp display for me the view from url.
Here is my configuration:
public class UiModule extends AbstractGinModule {
#Override
protected void configure() {
bind(AppView.Binder.class).in(Singleton.class);
bind(Footer.Binder.class).in(Singleton.class);
bind(GatekeeperProtectedMenuPanel.Binder.class).in(Singleton.class);
install(new GinFactoryModuleBuilder().build(MenuEntryFactory.class));
}
public class ClientModule extends AbstractPresenterModule {
#Override
protected void configure() {
bind(RestyGwtConfig.class).asEagerSingleton();
install(new DefaultModule.Builder()//
.defaultPlace(Routing.HOME.url)//
.errorPlace(Routing.ERROR.url)//
.unauthorizedPlace(Routing.LOGIN.url)//
.tokenFormatter(RouteTokenFormatter.class).build());
install(new AppModule());
install(new GinFactoryModuleBuilder().build(AssistedInjectionFactory.class));
bind(CurrentUser.class).in(Singleton.class);
bind(IsAdminGatekeeper.class).in(Singleton.class);
bind(UserLoginGatekeeper.class).in(Singleton.class);
// Load and inject CSS resources
bind(ResourceLoader.class).asEagerSingleton();
}
}
public class AppModule extends AbstractPresenterModule {
#Override
protected void configure() {
install(new UiModule());
// Application Presenters
bindPresenter(AppPresenter.class, AppPresenter.MyView.class, AppView.class, AppPresenter.MyProxy.class);
bindPresenter(HomePresenter.class, HomePresenter.MyView.class, HomeView.class, HomePresenter.MyProxy.class);
bindPresenter(ErrorPresenter.class, ErrorPresenter.MyView.class, ErrorView.class, ErrorPresenter.MyProxy.class);
bindPresenter(TestPresenter.class, TestPresenter.MyView.class, TestView.class, TestPresenter.MyProxy.class);
bindPresenter(PagePresenter.class, PagePresenter.MyView.class, PageView.class, PagePresenter.MyProxy.class);
bindPresenter(SettingsPresenter.class, SettingsPresenter.MyView.class, SettingsView.class, SettingsPresenter.MyProxy.class);
bindPresenter(FilesPresenter.class, FilesPresenter.MyView.class, FilesView.class, FilesPresenter.MyProxy.class);
bindPresenter(AdminAreaPresenter.class, AdminAreaPresenter.MyView.class, AdminAreaView.class, AdminAreaPresenter.MyProxy.class);
bindPresenter(LoginPresenter.class, LoginPresenter.MyView.class, LoginView.class, LoginPresenter.MyProxy.class);
}
}
This happens when I have GateKeeper on place's presenter.
Here is code:
public class UserLoginGatekeeper extends UserLoginModel implements Gatekeeper {
private final CurrentUser currentUser;
#Inject
UserLoginGatekeeper(CurrentUser currentUser) {
this.currentUser = currentUser;
}
#Override
public boolean canReveal() {
return currentUser.isLoggedIn();
}
}
In my main app presenter I execute asynhronous call to server to check is user login. If so I set client variable currentUser.setLoggedIn(true);. Base on this Gatekeeper allow access to restricted part of app.
I think the problem is that my asynhronous call is triggered to late. And GWTP redirect to default place.
Here is my app presenter code:
public class AppPresenter extends TabContainerPresenter<AppPresenter.MyView, AppPresenter.MyProxy> implements AppUiHandlers, CurrentUserChangedHandler, AsyncCallStartHandler, AsyncCallFailHandler,
AsyncCallSucceedHandler {
#ProxyStandard
public interface MyProxy extends Proxy<AppPresenter> {
}
public interface MyView extends TabView, HasUiHandlers<AppUiHandlers> {
void refreshTabs();
void setTopMessage(String string);
void setLoginButtonVisbility(boolean isVisible);
}
#RequestTabs
public static final Type<RequestTabsHandler> SLOT_REQUEST_TABS = new Type<>();
#ChangeTab
public static final Type<ChangeTabHandler> SLOT_CHANGE_TAB = new Type<>();
public static final NestedSlot SLOT_TAB_CONTENT = new NestedSlot();
private static final LoginService service = GWT.create(LoginService.class);
private final PlaceManager placeManager;
private final CurrentUser currentUser;
#Inject
AppPresenter(EventBus eventBus, MyView view, MyProxy proxy, PlaceManager placeManager, CurrentUser currentUser) {
super(eventBus, view, proxy, SLOT_TAB_CONTENT, SLOT_REQUEST_TABS, SLOT_CHANGE_TAB, RevealType.Root);
this.placeManager = placeManager;
this.currentUser = currentUser;
getView().setUiHandlers(this);
onStart();
}
protected void onStart() {
service.isCurrentUserLoggedIn(new MethodCallback<Boolean>() {
#Override
public void onFailure(Method method, Throwable exception) {
MaterialToast.fireToast("Fail to check is current user logged in " + method + " " + exception.getLocalizedMessage());
}
#Override
public void onSuccess(Method method, Boolean response) {
currentUser.setLoggedIn(response);
getView().setLoginButtonVisbility(response);
}
});
};
#ProxyEvent
#Override
public void onCurrentUserChanged(CurrentUserChangedEvent event) {
getView().refreshTabs();
}
#ProxyEvent
#Override
public void onAsyncCallStart(AsyncCallStartEvent event) {
getView().setTopMessage("Loading...");
}
#ProxyEvent
#Override
public void onAsyncCallFail(AsyncCallFailEvent event) {
getView().setTopMessage("Oops, something went wrong...");
}
#ProxyEvent
#Override
public void onAsyncCallSucceed(AsyncCallSucceedEvent event) {
getView().setTopMessage(null);
}
#Override
public void onLogoutButtonClick() {
service.logout(new MethodCallback<Void>() {
#Override
public void onFailure(Method method, Throwable exception) {
MaterialToast.fireToast("Fail to logout " + method + " " + exception.getLocalizedMessage());
}
#Override
public void onSuccess(Method method, Void response) {
MaterialToast.fireToast("You have been Succefully logout");
PlaceRequest request = new PlaceRequest.Builder(placeManager.getCurrentPlaceRequest()).nameToken(Routing.Url.login).build();
placeManager.revealPlace(request);
currentUser.setLoggedIn(false);
getView().setLoginButtonVisbility(false);
}
});
}
}
Working solution:
/**
*
*/
package pl.korbeldaniel.cms.client.gin;
import gwt.material.design.client.ui.MaterialToast;
import org.fusesource.restygwt.client.Method;
import org.fusesource.restygwt.client.MethodCallback;
import pl.korbeldaniel.cms.client.place.Routing;
import pl.korbeldaniel.cms.client.security.CurrentUser;
import pl.korbeldaniel.cms.client.service.LoginService;
import com.google.gwt.core.shared.GWT;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.Bootstrapper;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
import com.gwtplatform.mvp.shared.proxy.PlaceRequest;
/**
* #author korbeldaniel
*
*/
public class MyBootstrapper implements Bootstrapper {
private final PlaceManager placeManager;
private final CurrentUser currentUser;
private static final LoginService service = GWT.create(LoginService.class);
#Inject
public MyBootstrapper(PlaceManager placeManager, CurrentUser currentUser) {
this.placeManager = placeManager;
this.currentUser = currentUser;
}
#Override
public void onBootstrap() {
GWT.log("OnBootstrap");
service.isCurrentUserLoggedIn(new MethodCallback<Boolean>() {
#Override
public void onFailure(Method method, Throwable exception) {
MaterialToast.fireToast("Fail to check is current user logged in " + method + " " + exception.getLocalizedMessage());
placeManager.revealErrorPlace("Fail to check is current user logged in " + method + " " + exception.getLocalizedMessage());
}
#Override
public void onSuccess(Method method, Boolean response) {
// MaterialToast.fireToast("1Current user is logged in: " +
// response);
currentUser.setLoggedIn(response);
if (response == true) {
placeManager.revealCurrentPlace();
} else {
placeManager.revealPlace(new PlaceRequest.Builder().nameToken(Routing.Url.login).build());
}
}
});
};
}
Yeah, your backend call is asynchronous and most likely the UserLoginGatekeeper code will run before the backend call returns and the user gets redirected to the default page.
There are two solutions:
Use a dynamically generated host page (index.html) and set a javascript variable to the user details by the backend. You can read out the userdetails in a custom Bootstraper implementation and set the CurrentUser.
If you don't want to use a dynamically generated host page, you can also move the backend call isCurrentUserLoggedIn intot he custom Bootstrapper implementation and in the onSuccess callback reveal the first page (like in the above linked GWTP documentation)

GWT's Editor Framework and GWTP

building on this answer, i try to integrate the GWT editors into a popup presenter widget. What is the right way to do that?
My view looks like this:
public class DeviceEditorDialogView extends
PopupViewWithUiHandlers<DeviceEditorDialogUiHandlers> implements
DeviceEditorDialogPresenterWidget.MyView {
interface Binder extends UiBinder<PopupPanel, DeviceEditorDialogView> {
}
public interface Driver extends SimpleBeanEditorDriver<DeviceDto, DeviceEditorDialogView> {
}
#Inject
DeviceEditorDialogView(Binder uiBinder, EventBus eventBus) {
super(eventBus);
initWidget(uiBinder.createAndBindUi(this));
}
#Override
public SimpleBeanEditorDriver<DeviceDto, ?> createEditorDriver() {
Driver driver = GWT.create(Driver.class);
driver.initialize(this);
return driver;
}
}
and my presenter looks like this:
public class DeviceEditorDialogPresenterWidget extends PresenterWidget<DeviceEditorDialogPresenterWidget.MyView> implements
DeviceEditorDialogUiHandlers {
#Inject
DeviceEditorDialogPresenterWidget(EventBus eventBus,
MyView view) {
super(eventBus, view);
getView().setUiHandlers(this);
}
/**
* {#link LocalDialogPresenterWidget}'s PopupView.
*/
public interface MyView extends PopupView, DevicesEditView<DeviceDto>, HasUiHandlers<DeviceEditorDialogUiHandlers> {
}
private DeviceDto currentDeviceDTO = null;
private SimpleBeanEditorDriver<DeviceDto, ?> driver;
public DeviceDto getCurrentDeviceDTO() {
return currentDeviceDTO;
}
public void setCurrentDeviceDTO(DeviceDto currentDeviceDTO) {
this.currentDeviceDTO = currentDeviceDTO;
}
#Override
protected void onBind() {
super.onBind();
driver = getView().createEditorDriver();
}
//UiHandler Method: Person person = driver.flush();
}
Is this the right approach? What is missing? Currently nothing happens when i try to use it like this:
#Override
public void showDeviceDialog() {
deviceEditorDialog.setCurrentDeviceDTO(new DeviceDto());
addToPopupSlot(deviceEditorDialog);
}
showDeviceDialog is in the parent presenter and called when clicking a button in that parent Presenter, that instantiates the dialog with private final DeviceEditorDialogPresenterWidget deviceEditorDialog;
Thanks!
Here are a few key points that are missing from your code above:
Your DeviceEditorDialogView should implement Editor<DeviceDto>. This is required in order for the fields of DeviceEditorDialogView to be populated with data from you POJO.
Your DeviceEditorDialogView should have child editors that are mapped to fields in your POJO. For example, given the field deviceDto.modelName (type String), you could have a GWT Label named modelName in your DeviceEditorDialogView. This Label implements Editor<String> and will be populated with the modelName from your DeviceDto when you call driver.edit(deviceDto)
You should call driver.initialize(this) only once, in DeviceEditorDialogView's constructor
You should override onReveal() like this:
#Override
public void onReveal() {
super.onReveal();
driver.edit(currentDeviceDTO); // this will populate your view with the data from your POJO
}
This method will be called when the popup is displayed, just after your DeviceEditorDialogPresenterWidget has been addToPopupSlot

GWT Platform UiHandlers not working

I have followed the GettingStarted on the GWTP tutorial
http://code.google.com/p/gwt-platform/wiki/GettingStarted
but unfortunately handlers not working, getUiHandlers() return null and exception stacktrace is same as in:
How to use UiHandlers of GWT Platform?
.
View Class
public class AView extends ViewWithUiHandlers<AUiHandlers> implements APresenter.Display {
#UiTemplate("AView.ui.xml")
interface AViewUiBinder extends UiBinder<Widget, AView> {}
private static AViewUiBinder uiBinder = GWT.create(AViewUiBinder.class);
#UiField Button saveBtn;
#UiField Button cancelBtn;
#UiField DivElement errorDiv;
private Widget widget;
#Inject
public AssetView() {
widget = uiBinder.createAndBindUi(this);
}
public Widget asWidget() {
return widget;
}
// Implementation: Presenter's Display methods
public void setErrorDivText(String msg) {
errorDiv.getStyle().setDisplay(Display.BLOCK);
errorDiv.setInnerText(msg);
}
// Handlers
#UiHandler("saveBtn")
void onSaveButtonClick(ClickEvent event) {
if(getUiHandlers() != null) {
getUiHandlers().onSaveButtonClick();
}
}
#UiHandler("cancelBtn")
void onCancelButtonClick(ClickEvent event) {
if(getUiHandlers() != null) {
getUiHandlers().onCancelButtonClick();
}
}
}
Handler Interface
public interface AUiHandlers extends UiHandlers {
void onSaveButtonClick();
void onCancelButtonClick();
}
Presenter
public class APresenter extends Presenter<APresenter.Display, APresenter.AssetProxy> implements AUiHandlers {
public interface Display extends View, HasUiHandlers<AUiHandlers> {
public void setErrorDivText(String msg);
}
#ProxyStandard
#NameToken(NameTokens.ASSET)
public interface AssetProxy extends ProxyPlace<AssetPresenter> {}
#Inject
public AssetPresenter(EventBus eventBus, Display view, AssetProxy proxy) {
super(eventBus, view, proxy);
getView().setUiHandlers(this);
}
#Override
protected void onBind() {
super.onBind();
}
#Override
protected void revealInParent() {
RevealRootContentEvent.fire( this, this );
}
public void onSaveButtonClick() {
getView().setErrorDivText("Save clicked.");
}
public void onCancelButtonClick() {
getView().setErrorDivText("Cancel clicked.");
}
}
Unable to understand where i am making mistake, implementation regarding UiHandlers is same as told in the above mentioned tutorial's link.
UiHandlers is not generic; it cannot be parameterized with arguments
As I see your handler interface, you have passed AUiHandlers type. I don't understand the package structure of UiHandlers . it should be com.gwtplatform.mvp.client.UiHandlers.
Please check import of it.
Update:
Remove private static AViewUiBinder uiBinder = GWT.create(AViewUiBinder.class);
and Pass as constructor argument
#Inject
public AssetView(AViewUiBinder uiBinder) {
widget = uiBinder.createAndBindUi(this);
}

PlaceRequest with parameters to Popup Presenter

I trying to pass a parameter in the placerequest to a presenter that will be a popup, but, the i receive empty parameters in the popup presenter.. am i forgot anything?
AddProjetoPresenter
public class AddProjetoPresenter extends Presenter<AddProjetoPresenter.AddProjetoView, AddProjetoPresenter.AddProjetoProxy>
{
#ProxyCodeSplit
#NameToken(NameTokens.addproj)
public interface AddProjetoProxy extends ProxyPlace<AddProjetoPresenter>
{
}
public interface AddProjetoView extends View
{
HasValue<String> getNome();
HasValue<Date> getDtInicio();
HasValue<Date> getDtFim();
HasClickHandlers getAddRequisitos();
HasClickHandlers getAddStakeholders();
HasClickHandlers getBtCancelar();
HasClickHandlers getBtSalvar();
}
private final DispatchAsync dispatch;
private final PlaceManager placeManager;
private Projeto projeto;
#Inject
public AddProjetoPresenter(final EventBus eventBus, final AddProjetoView view, final AddProjetoProxy proxy, final DispatchAsync dispatch,
final PlaceManager placeManager)
{
super(eventBus, view, proxy);
this.dispatch = dispatch;
this.placeManager = placeManager;
}
#Override
protected void revealInParent()
{
RevealContentEvent.fire(this, MainPresenter.TYPE_SetMainContent, this);
}
#Override
protected void onBind()
{
super.onBind();
getView().getBtSalvar().addClickHandler(new ClickHandler()
{
#Override
public void onClick(ClickEvent event)
{
}
});
getView().getAddRequisitos().addClickHandler(new ClickHandler()
{
#Override
public void onClick(ClickEvent event)
{
PlaceRequest pr = new PlaceRequest(NameTokens.addreq);
pr.with("oi", "oiiiii"); // HERE
placeManager.revealPlace(pr, false);
}
});
}
}
AddRequisitoPresenter
public class AddRequisitoPresenter extends Presenter<AddRequisitoPresenter.AddRequisitoView, AddRequisitoPresenter.AddRequisitoProxy>
{
#ProxyCodeSplit
#NameToken(NameTokens.addreq)
public interface AddRequisitoProxy extends ProxyPlace<AddRequisitoPresenter>
{
}
public interface AddRequisitoView extends PopupView
{
DialogBox getDialog();
}
private final DispatchAsync dispatcher;
private Projeto projeto;
#Inject
public AddRequisitoPresenter(final EventBus eventBus, final AddRequisitoView view, final AddRequisitoProxy proxy, final DispatchAsync dispatcher)
{
super(eventBus, view, proxy);
this.dispatcher = dispatcher;
}
#Override
public void prepareFromRequest(PlaceRequest request)
{
super.prepareFromRequest(request);
getView().getDialog().setText(request.getParameterNames().size() + ""); //SIZE IS ZERO!!
}
#Override
protected void onBind()
{
super.onBind();
}
#Override
protected void revealInParent()
{
RevealRootPopupContentEvent.fire(this, this);
}
}
I think ai doing something wrong...
thanks in advance.
From what I understood in the wiki, a popup can't be a place, and it needs a parent presenter.
I see two obvious problems here :
Your second presenter (the popup) should implement PresenterWidget, not Presenter
You can't display a popup by calling placeManager.revealPlace(), because a popup is not a place. Instead, you have to apply one of the two methods explained in the wiki (addToPopupSlot() or RevealRootPopupContentEvent.fire(), both called from the parent).

GIN & GWT: Binding Presentation layer with View

I'm trying to bind a GWT view with its presentation layer, but it doesn't seem to be doing anything.
It's a Spring Roo GWT generated project and I'm trying to use the scaffold given as far as possible.
The view is a simple button (R.ui.xml) and the rest of the view is defined in R.java:
public class R extends Composite implements RPresenter.Display {
interface MyUiBinder extends UiBinder<Widget, R> {}
private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
#UiField Button myButton;
private ClickHandler buttonClickHandler = null;
public R(){
initWidget(uiBinder.createAndBindUi(this));
}
#UiHandler("myButton")
void onButtonClick(ClickEvent event){
GWT.log('Button clicked');
if (buttonClickHandler != null){
GWT.log("buttonClickHandler event triggered");
buttonClickHandler.onClick(event);
}
}
#Override
public void setButtonClickHandler(ClickHandler buttonClickHandler) {
GWT.log("setButtonClickHandler");
this.buttonClickHandler = buttonClickHandler;
}
}
The presenter:
public class RPresenter {
public interface Display extends IsWidget {
void setButtonClickHandler(ClickHandler buttonClickHandler);
}
private final Display display;
private final EventBus eventBus;
#Inject
public RPresenter(EventBus eventBus, Display display){
this.display = display;
this.eventBus = eventBus;
bind();
}
private void bind(){
display.setButtonClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent event) {
GWT.log("onClick event triggered");
}
});
}
public void go(HasWidgets container){
container.add(display.asWidget());
}
}
And for my GIN module I use the generated ScaffoldModule in the ...client.scaffold.ioc package:
public class ScaffoldModule extends AbstractGinModule {
#Override
protected void configure() {
GWT.log("ScaffoldModule 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(RPresenter.Display.class).to(R.class).in(Singleton.class);
bind(RPresenter.Display.class).to(R.class);
}
static class PlaceControllerProvider implements Provider<PlaceController> {
private final EventBus eventBus;
#Inject
public PlaceControllerProvider(EventBus eventBus) {
this.eventBus = eventBus;
}
public PlaceController get() {
return new PlaceController(eventBus);
}
}
static class RequestFactoryProvider implements Provider<ApplicationRequestFactory> {
private final EventBus eventBus;
#Inject
public RequestFactoryProvider(EventBus eventBus) {
this.eventBus = eventBus;
}
public ApplicationRequestFactory get() {
ApplicationRequestFactory requestFactory = GWT.create(ApplicationRequestFactory.class);
requestFactory.initialize(eventBus);
return requestFactory;
}
}
}
In the GWT development mode console, the "ScaffoldModule configure" never displays, yet the generated scaffold seems to binding just fine as the events get passed along from component to component without a hitch, unless the binding is magically happening somewhere else and that is dead code.
When I put my bind(RPresenter.Display.class).to(R.class) in, it doesn't seem to do the binding. The only output I get in the GWT console is "Button clicked" which is called in the view and then nothing further. I'm clearly missing something, any ideas?
The call to GWT.log() will not output anything from an AbstractGinModule - classes that extend AbstractGinModule (ScaffoldModule in your situation) are used by gin at compile time to decide which concrete implementations to use for injected interfaces. From the rest of your description (i.e. that the UI shows up in the application) it appears that your dependency injection is working correctly.