MVP pattern assumes that View expose methods to Presenter. For example in View we can write:
public HasClickhandlers getButton() {
return myBtn;
}
and access to this method from presenter, like
view.getButton().addclickhanlder() ...
But when I build my app in this style, I have a lot unnecessary code. For example I want to create TablesView
and TablesPresenter
(I decide thatTablesPresenter
and TablesView
is minimal entity (minimal module), that can not be divided into more small presenters and views, and can not be more complex). Then, when I create TablesView
, I want to put inside this view another custom component - MyCustomTable
. And Inside MyCustomTable
put MyCustomHeader
, inside MyCustomHeader
put MyCustomFilter
and so on (this sequence may be much longer)...
So problem is when I want to access from Presenter to entered text(by user) inside MyCustomFilter
, I need to expose method on MyCustomFilter
:
//inside MyCustomFilter
public String getFilterText() {
return textBox.getText();
}
then in widget that contains MyCustomFilter
- i.e. in MyCustomHeader
I need to expose this method:
//inside MyCustomHeader
public String getFilterText() {
return myCustomFilter.getFilterText();
}
after it, inside MyCustomTable
I need to expose this method:
//inside MyCustomTable
public String getFilterText() {
return myCustomHeader.getFilterText();
}
After it I need to expose getFilterText()
method inside TablesView
(that contains MyCustomTable
) and after all this operations my presenter can access to text inside MyCustomFilter
.. And sometime this sequence is more longer.
So how to solve this problem? May be I not understand some things about MVP?