Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have probably seen this Google I/O presentation: <a href="http://www.google.com/events/io/2009/sessions/GoogleWebToolkitBestPractices.html" rel="noreferrer">Google Web Toolkit Architecture: Best Practices For Architecting Your GWT App</a>. </p> <p>It covers neat techniques to make working with a large GWT projects more managable, like using the Command Pattern for RPC calls, the MVP pattern, Dependency Injection, and decoupling components using the EventBus pattern. Now there are several GWT frameworks that implement these patterns, (<strong>gwt-dispatch</strong> for Command pattern, <strong>gwt-presenter</strong> and <strong>gwt-platform</strong> for MVP, <strong>GIN &amp; Guice</strong> for DI) but the thing I like about the EventBus concept is that it's part of the core GWT framework (<code>HandlerManager</code>), so I don't have to add extra dependencies to smaller GWT projects.</p> <p>I think the EventBus concept is related to the <strong>Observer</strong> design pattern in the sense that you are decoupling the View components responsible for getting user input from the Presenter components that need to be notified about those actions. The point is that your ListBox thingy doesn't have to know about all the components that are interested in its state change, it just fires an event to the EventBus, and the interested components will receive that event and act however they want. </p> <p>I don't think you always have to do things through the HandlerManager instance though. Suppose you have a custom <code>DateRangePicker</code> widget, that lets users pick custom date ranges. Whenever a date range is picked, the widget can do something like this in its <code>onSomethingChanged()</code> method :</p> <pre><code>NativeEvent event = Document.get().createChangeEvent(); DomEvent.fireNativeEvent(event, this); </code></pre> <p>Then the components interested in the date range selection change could just register hander callbacks to the DateRangePicker widget instances.</p> <pre><code>dateRangePicker.addDomHandler(new ChangeHandler(){ @Override public void onChange(ChangeEvent event) { refresh(); } }, ChangeEvent.getType()); </code></pre> <p>I think this is a nice loosely coupled design and it doesn't use a <code>HandlerManager</code> instance.</p> <p>A bad design would be to call all the interested component's <code>refresh()</code> methods in the DateRangePicker's onSomethingChange() method instead of firing an event. (Or even worse: calling all the refresh()-es in, the DateRangePicker object's subcomponent's onSomethingChange() methods.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload