I don't think that there's currently a way to do this. You'd still
need to put some attribute on your "anonymous" Label so that you could
look it up, much like an HTML id attribute. Still, the lookup would
need some kind of reflection mechanism, or UiBinder would have to
gather everything in the template to provide a lookup mechanism. At
the very least, you'd lose all type safety because you would be able
to look up any type of widget.

The main thing that I wanted to mention is that you don't have to
think of the .ui.xml's corresponding .java as the presenter in an MVP
application. I instead think of it as part of the view and then
provide a separate presenter class. Yes, it is now 3 files instead of
2, but the UiBinder layout is much easier to understand than the
equivalent java. Following from that, it is OK for your views java
code to have references to concrete widget types.

There is one convenience that this appears to leave out, though:
@UiHandler. These are things that MVP tells us should be in the
presenter, yet the annotation has to live in the view class instead. I
haven't fully worked out my thoughts on this yet, but having already
done MVP without UiBinder, I don't feel burdened by not using
@UiHandler. Some have talked about having the presenter register
callbacks with the view that the view can then call from @UiHandler
annotated methods, which seems cumbersome to me. Others have talked
about letting the view hold a reference to the presenter to call
specific methods (maybe defined in a presenter interface) from
@UiHandler methods. This may not be a bad approach, but I haven't
tried it myself yet.

-Brian

On Apr 11, 10:59 pm, Andrew Hughes <ahhug...@gmail.com> wrote:
> Hi Guys,
>
> Sure, it's easy with UIBinder to add an "anonymous"/"on the fly" child
> widget without declaring  '*...@uifield Label blah;*' in the java class or 
> *'**
> ui:Field="blah"' *in the ui.xml template.
>
> For example, here there is no '*...@uifield Label blah;*' in the java class 
> and
> there is no  *'**ui:Field="blah"' *in the ui.xml template.
>
>  <g:Label TEXT="Here's a Label widget that's not declared or annoated in the
> containing java code"/>
>
> The problem:
> I do not want '*...@uifield Label blah;*' in the java class, this is in
> complete contradiction to the MVP pattern we're trying out best to follow.
> So, declaring these anonymously (as above is great). But at the same time,
> we don't want to just use some anonymous "Label" instance that the UIBinder
> creates for me. Can I programatically work with the UIBinder so that I can
> provide the "Label" I want it to use without '*...@uifield Label blah;*' in 
> the
> containing java (parent/widget) class?
>
> Cheers
> --AH

-- 
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-tool...@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.

Reply via email to