On Tuesday, May 15, 2012 1:58:48 PM UTC+2, Shaun Tarves wrote:
>
> Sorry for not being clearer - self-contained wasn't the correct 
> description. Modular is more what I meant; widgets in the sense that they 
> could be used in multiple views, but still have the ability to interact 
> with the rest of the app (fire events mostly). If they're widgets as used 
> in uiBinder templates, how to I control the construction of them to include 
> an event bus. Should I make the event bus static, declare a UiConstructor, 
> or use injection?


Don't make the bus static!

You can use @UiFactory, @UiConstructor if you wish, or 
@UiField(provided=true).

In some very specific cases (because we had a lot of those widgets –a 
SuggestBox that needed a RequestFactory in our case– and a lot of views, 
and didn't want to add too much boilerplate in each view), we added a 
static field into the widget and used GIN's requestStaticInjection 
(ideally, you'd rather inject a Provider<> and call its get() from your 
constructor, to mimic dependency-injection).
This is only a workaround for the fact UiBinder isn't really GIN-friendly; 
it should IMO be explicitly documented in your code as being a workaround, 
and not a rule to follow ! (rather an exception to the rule).
See also http://code.google.com/p/google-web-toolkit/issues/detail?id=6151

I'm mostly looking for a design pattern that others have found helpful with 
> actual implementation (where/how to declare/construct) of MVP widgets.
>

See 
http://www.google.com/events/io/2010/sessions/gwt-continuous-build-testing.html 
for 
an example of a presenter asking its view for a sub-view (and then 
attaching a sub-presenter to that sub-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/-/oYWxOSgk3a8J.
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