Thanks all yours responses.
Le jeudi 18 octobre 2012 17:25:14 UTC+2, Thad a écrit :
>
> On Wednesday, October 17, 2012 5:28:16 PM UTC-4, furious_panda wrote:
>
>> 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 ?*
>>
>
> I have not been hard and fast about hiding POJOs from my my views. After
> all, a view has to know what to display and I find oodles of getFoo() are a
> lot work for the return. However I put all updating of my POJOs in my
> activities. Each time the view need to display something, it gets it from
> the activity. The activity handles setDirty(true|false). This seem easiest
> for my mind to grasp.
>
> 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.
>>
>
> If your using a FlexTable, look at samples/Mail for how this is done. I've
> implemented something akin to this *many* times (though now I'm moving
> larger data sets to cells).
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/xortaej27p4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.