Re: UI handling doubt in MVP

2012-01-14 Thread Thomas Broyer


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 ValueListBoxXxx combo;
@UiFied TextBox yyy;

@UiHandler('combo)
void onComboValueChanged(ValueChangeEventXxx 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 google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: UI handling doubt in MVP

2012-01-14 Thread Qrunk
thanks for the prompt replies . I think I got the perfect answers

-- 
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/-/OBx_8uKSmc4J.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: UI handling doubt in MVP

2012-01-14 Thread Qrunk
Hi,


Using the Editor framework though blurs the line between presenter and view

Can you please elaborate this and would be very useful if you do that using 
an example.

Thanks

-- 
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/-/R-vhs0sBxYsJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



UI handling doubt in MVP

2012-01-13 Thread Qrunk
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.

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)
2. As i want to make an UI related change in my page, this event should be 
handled by the View class.

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
 

-- 
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/-/BFI-pTM5--YJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: UI handling doubt in MVP

2012-01-13 Thread Eric Metcalf
You want to put all of your logic into the presenter without putting
any of the widget code in that would prevent tests from running.

For the ListBox you want to declare a ChangeHandler on it in the
Presenter.  To do that you have the View return back the ListBox as an
interface of HasChangeHandler.

@UiHandler ListBox fooItems;

public HasChangeHandler getHasChangeHandler() {
  return fooItems;
}

You will also have to have the View return back the selected item
since I don't see any interfaces you can return to do that.

public String getItem() {
  return fooItems.getItemText(fooItems.getSelectedIndex());
}

Finally the view can return back the TextBox has a HasEnabled
interface so the presenter can disable it.

@UiBinder TextBox textBox;

public HasEnabled getHasEnabled() {
  return textBox;
}

Now the presenter can call these to get the item when selected and
disable the text box if needed.

view.getHasChangeHandler().addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
  view.getItem();
  view.getHasEnabled().setEnabled(false);
}
  }
);



On Jan 13, 2:05 am, Qrunk kapil2ka...@gmail.com wrote:
 Hi ,

 Im a bit confused as in what does UI handling is meant 
 inhttp://code.google.com/webtoolkit/articles/mvp-architecture.html,  which is
 to be handled by the presenter.

 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)
 2. As i want to make an UI related change in my page, this event should be
 handled by the View class.

 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 
 alsohttp://tbroyer.posterous.com/gwt-211-requestfactory-part-ii

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.