You should be able to find what you are looking for under "Large scale application development and MVP - parts 1 and 2"
I've long since abandoned the notion of hiding my pojos from my views so I guess I'm in MVC denial.
Hi,
I need some help, I did not found examples or forums discussions about these subjects.
I want to try to do a GWT application using MVP pattern. But I have some difficulties.
In MVP, Presenter have to contain Display interface that specifie what the View must implements and return.
I have two problems when I apply this pattern:
1 - The View must not have to manipulate Model. Or, how it is possible for a collections of objects?
For example, I have model object Person as follows:
public class Person{
private String firstname;
private String lastname;
private Integer age;
......
}
The View must display a collection of Person in Table (Flextable for example) whithout manipulating Model. How it is possible ?
This is my presenter, and what I do now:
public class PersonListPresenter extends WidgetPresenter<PersonListPresenter .Display> {
public interface Display extends WidgetDisplay{
public void setData(List<Person> data);
}
protected void onBind() {
display.setData(data);
}
}
This is my view, and what I do now:
public class SongsView implements PersonListPresenter .Display {
......
public void setData(List<Person> data) {
if(data!=null && data.size() > 0){
for (Person person: data) {
// I display all information about each Person in one row of table
}
}
}
.....
}
How can I do in MVP for this case ?
2 - My second problem, is each row of this table must be clickable ? How I can do ?
How can I get from display click event for each row ?
public class PersonListPresenter extends WidgetPresenter<PersonListPresenter .Display> {
public interface Display extends WidgetDisplay{
public void setData(List<Person> data);
}
protected void onBind() {
display.setData(data);
// I have to implement the same information for each row but the source information is different.
// I have to fire an Event containing the Person information that is clicked
display.get ?????
.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
}
}
}
}
Thanks in advance.