Open GoogleCodeExporter opened 9 years ago
I think it needs to add some specific parser to UiBinder. Unfortunately, it's
currently available:
http://code.google.com/p/google-web-toolkit/issues/detail?id=4461
There is another way but it sounds like a hack: create a glue widget that (1)
implements HasWidgets and (2) have a add method taking a Presenter.
The goal:
<g:FlowPanel>
<p:Glue>
<p:MyPresenter/>
<p:Glue>
</g:FlowPanel>
(1) In ui.xml file, a tag can have sub-tags only if its widget's class implement
HasWidgets. So:
class Glue ... implements HasWidgets {
public void add(Widget w) { throw new UnsupportedOperationException(); }
...
}
No need to really implements them because we don't want to put some widgets
into.
(2) You can add a tag of representing any class if it's container has a add
method
with parameter of the same type. So:
class Glue ... {
public void add(Widget w) { ... }
public void add(Presenter p) { setTheWidgetTo(p.getView().asWidget()); }
}
But it's really, really, really a bad way ;)
Original comment by olivier....@free.fr
on 22 May 2010 at 5:29
I'm really waiting for a solution to this problem. This is a blocker for me.
GWTP is great but I do not want to lose flexibily provided by uiBinder.
Original comment by nicolas....@gmail.com
on 14 Jun 2010 at 9:26
Thanks for the input Nicolas. Just to make it clear, however: GWTP has very
strong support for UiBinder already. This would be a small added bonus. From
what I know, no MVP solution out there allows something like this.
That being said, I'll look into it since it's really something I'd love to see.
Original comment by philippe.beaudoin
on 14 Jun 2010 at 3:33
Thanks philippe.
Indeed, no MVP solutions answer to this. This is what I discovered few hours
ago. I implemented a solution using the slot content mechanism (without
uiBinder) and it worked fine.
When I wrote this comment, I did not really understand what where the process
behind it.
However, it would be great to be able to insert a simple PresenterWidget in
uiBinder. (But this is clearly not a blocker like I just wrote before).
Original comment by nicolas....@gmail.com
on 14 Jun 2010 at 4:09
Original comment by philippe.beaudoin
on 6 Jul 2010 at 7:44
Else, by referencing the presenter in the view, you can add the view directly
as expected to UiBinder files and it works fine. The only problem is that you
can't use the proxy mechanism that way.
For me, that issue is a WontFix because of this.
Original comment by goudreau...@gmail.com
on 17 Aug 2010 at 1:47
Original comment by philippe.beaudoin
on 22 Sep 2010 at 1:35
A new @UiChild annotation has been added to GWT, maybe we could use it? See:
http://code.google.com/p/google-web-toolkit/issues/detail?id=4461
https://wave.google.com/wave/waveref/googlewave.com/w+WIuSfOKhA
Original comment by philippe.beaudoin
on 28 Oct 2010 at 6:59
I already tried to include a view inside UiBinder and injecting the presenter
of that view inside another presenter...
Realllllyyy bad idea ! LOL
Original comment by goudreau...@gmail.com
on 28 Oct 2010 at 7:02
Today I have committed some classes that constitutes the first step towards
solving this issue. With r5b2202c604 it is now possible to use your @Inject-ed
custom widgets within your UiBinder .ui.xml files. In other words, GWTP offers
an upgraded version of UiBinder that supports dependency injection.
To use that feature you need:
1) To use <inherits name="com.google.gwt.uibinder.GinUiBinder" /> instead of
com.google.gwt.uibinder.UiBinder in your module
2) To identify your ginjector class in your module by defining a gin.gingector
configuration property. You probably do this already if you're using GWTP.
3) To define a getMyCustomWidget() method in your ginjector for every custom
widget that participates in DI.
I'd really like to remove constraints (2) and (3) but for now I don't know how
to do this. If anybody has an idea of a better way to use DI in a generated
file, it would be most welcome!
Original comment by philippe.beaudoin
on 13 Nov 2010 at 10:20
Some examples of custom widgets using @Inject are available in TabSample.
Original comment by philippe.beaudoin
on 13 Nov 2010 at 10:49
"Today I have committed some classes that constitutes the first step towards
solving this issue. With r5b2202c604 it is now possible to use your @Inject-ed
custom widgets within your UiBinder .ui.xml files. In other words, GWTP offers
an upgraded version of UiBinder that supports dependency injection."
Just to be sure I understand you correctly:
The advantage of this is that I dont have to use "provided=true" anymore and
Inject and set the widget in the constructor?
Original comment by opn...@googlemail.com
on 25 Nov 2011 at 9:59
@opncow That's correct.
Original comment by philippe.beaudoin
on 25 Nov 2011 at 1:31
Would it be possible for PresenterWidget to implement
com.google.gwt.user.client.ui.IsWidget?
Then at least if the PresenterWidget is provided by the view or GinUiBinder
injected the ui framework can handle binding the class.
Original comment by josephalevin
on 30 Jan 2012 at 4:43
The goal of presenter widget is to have nothing to do with the widget side of
things, so I don't think we should go ahead with this proposal. Really, it's
the view you want to add not the presenter widget...
Original comment by philippe.beaudoin
on 2 Feb 2012 at 5:21
I agree, and presenter widget is in fact added to GWTP lifecycle if added with
setInSlot and family methods. By by passing that, that means that extending
PresenterWidget itself doesn't mean anything anymore.
Original comment by goudreau...@gmail.com
on 2 Feb 2012 at 5:24
setInSlot makes it easy to reuse PresenterWidget/View in multiple Presenters.
But how to do to reuse this mechanism for Dialogs? I have a dialog sharing the
same piece of view as other dialogs and presenters.
Original comment by cnak...@virtuoz.com
on 22 Mar 2012 at 1:41
Original issue reported on code.google.com by
philippe.beaudoin
on 29 Apr 2010 at 5:17