I've been learning GWT the past couple months and found out that the Mvp is one of the best ways to design your project. I've read google's tutorial MVP part 1 and in their tutorial they put the clickHandlers ( for example) in the presenter. Now I had problems with that when constructing many view class that has many buttons with the same HTML id, and then the user interacts with these buttons... so if I have one button for every view, total 6 button. and the user clicks on one of them, the button will work 6 times for the same object... So I read and found out that it is better to put the handlers on the view class and create an event to the presenter.
So that what I did :
View Class :
rb0.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
selectHandler.onEvent(1);
System.out.print("rate 1");
}
});
rb1.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
selectHandler.onEvent(2);
System.out.print("rate 2");
}
});
rb1.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
selectHandler.onEvent(3);
System.out.print("rate 3");
}
});
rb1.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
selectHandler.onEvent(4);
System.out.print("rate 4");
}
});
rb1.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
selectHandler.onEvent(5);
System.out.print("rate 5");
}
});
Presenter class : (event handler)
private void bind() {
.
.
.
DoEvent selectHandler = new DoEvent(){
public void onEvent(int select) {
fetchRating(select, user.getUserId());
}
};
display.setSelectHandler(selectHandler);
The call for the Presenter with it's view, it is called from the MainPagePresenter class :
presenter = new AssetViewPresenter(rpcService,eventBus,new AssetView(),result.get(i));
now my problem is that when I click the buttons from the view nothing happens... like the presenter and the view are not connected, what could be the problem ?