On Friday, January 13, 2012 9:05:22 AM UTC+1, Qrunk wrote:
>
> Hi ,
>
> Im a bit confused as in what does UI handling is meant in 
> http://code.google.com/webtoolkit/articles/mvp-architecture.html,  which 
> is to be handled by the presenter.
>

First: skip directly to the "part 2" article.

Say I have a case where when I change my combo box , I want a UI 
> widget(Text Box ) to be disabled. Now here there are two things:
>
> 1. I have to check through the data which I clicked inside the combo Box, 
> which I believe should make my event to be handled by the presenter as my 
> UI shouldn't be aware of my data part(Models)
>

"my UI shouldn't be aware of my data part" is an anti-pattern; it implies 
too much abstractions, and leads to over-engineered and hard to maintain 
code.
 

> 2. As i want to make an UI related change in my page, this event should be 
> handled by the View class.
>

Because it's related to your "presentation logic", it should go through to 
the presenter.

interface Presenter {
   void onSelectedXxxChanged(Xxx selectedItem);
}

interface View {
   void setYyyEnabled(boolean enabled);
}

Then in your presenter:
@Override
public void onSelectedXxxChanged(Xxx selectedItem) {
   boolean enabled = shouldEnableYyy(selectedItem); // your logic
   view.setYyyEnabled(enabled);
}

And in your view:

@UiField ValueListBox<Xxx> combo;
@UiFied TextBox yyy;

@UiHandler('combo")
void onComboValueChanged(ValueChangeEvent<Xxx> event) {
   presenter.onSelectedXxxChanged(event.getValue());
}

@Override
public void setYyyEnabled(boolean enabled) {
   yyy.setEnabled(enabled);
}

Please let me know where and how should I delegate the event to event 
> handlers on selection of the combo box item.
> Should it be handled within Presenter, which cant happen because the 
> presenter doesn't has any knowledge of the View component(in our case the 
> Text Box that is to be disabled) or it should be handled within the View 
> class, but this shouldn't happen as the View should be unaware of the Data 
> part.and want some inputs on Request factory also
> http://tbroyer.posterous.com/gwt-211-requestfactory-part-ii


Whether you use RF or not doesn't change anything (using the Editor 
framework though blurs the line between presenter and view).

-- 
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/-/8pmXcn2aXWYJ.
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.

Reply via email to