Pass parameters to PresenterWidget

103 views
Skip to first unread message

Lucas Mansbridge

unread,
May 10, 2012, 3:42:48 AM5/10/12
to gwt-pl...@googlegroups.com
Hi, I have a PresenterWidget that I instantiate by wrapping in a Provider and calling get().  Is there a way I can pass it constructor parameters?  Or can I only pass it objects after it's instantiated?

Thanks,

Lucas

Christian Goudreau

unread,
May 12, 2012, 9:27:17 PM5/12/12
to gwt-pl...@googlegroups.com
You will have to use Gin assited injection feature to do that.

Cheers,
--
Christian Goudreau

Lucas Mansbridge

unread,
May 13, 2012, 7:02:09 PM5/13/12
to gwt-pl...@googlegroups.com
I only wish to pass simple arguments like int and String. Should I then create a container class for these as a singleton and inject it? Or is there a simpler way?

Raphael André Bauer

unread,
May 14, 2012, 9:47:10 AM5/14/12
to gwt-pl...@googlegroups.com
On Mon, May 14, 2012 at 1:02 AM, Lucas Mansbridge
<lucasma...@gmail.com> wrote:
> I only wish to pass simple arguments like int and String. Should I then
> create a container class for these as a singleton and inject it? Or is there
> a simpler way?

Assisted inject is the way to go (as Christian already pointed out).

Another simpler way is to use a simple method setMyInt(int i) and call
it after the provider.get().
Pro:
- Simpler than assisted inject
Con:
- More error prone as you can forget it and then your presenter does not work...


Cheers,

ra

>
> On 13/05/2012, at 11:27 AM, Christian Goudreau
> <goudreau....@gmail.com> wrote:
>
> You will have to use Gin assited injection feature to do that.
>
> Cheers,
>
> On Thu, May 10, 2012 at 3:42 AM, Lucas Mansbridge
> <lucasma...@gmail.com> wrote:
>>
>> Hi, I have a PresenterWidget that I instantiate by wrapping in a Provider
>> and calling get().  Is there a way I can pass it constructor parameters?  Or
>> can I only pass it objects after it's instantiated?
>>
>> Thanks,
>>
>> Lucas
>
>
>
>
> --
> Christian Goudreau
> www.arcbees.com
>



--
inc: http://ars-machina.raphaelbauer.com
tech: http://ars-codia.raphaelbauer.com
web: http://raphaelbauer.com

Christian Goudreau

unread,
May 14, 2012, 9:49:10 AM5/14/12
to gwt-pl...@googlegroups.com
Con:
- If those are meant to be immutable, setters will make them mutable.
--
Christian Goudreau
Reply all
Reply to author
Forward
0 new messages