Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instantiate a PresenterWidget (GWTP) manually

i am new to GWT, GWTP.

I have a PresenterWidget which gets instantiated multiple times and gets added to a slot. I want to define the amount of instances programmatically. I only know that I make a new Instance of the Widget by Injecting it.

@Inject MyWidgetPresenter first; 
@Inject MyWidgetPresenter second; 
// ...

Can I instantiate it with new? how do instantiate the view?

I tried to use a composite because it seemed to be the smartest solution, because it doesnt contain much logic anyway. But I cant add a composite to a slot.

Thanks in advance

like image 394
nsrlady Avatar asked Jan 22 '26 16:01

nsrlady


1 Answers

In GWTP 1.0 the Ginjector is not needed anymore (auto-generated by gwtp).

In your case (and each time you need multiple instance of a class) the best is to inject a Provider of your WidgetPresenter:

@Inject Provider<MyWidgetPresenter> myWidgetPresenterProvider; 

Each time you need a new instance of MyWidegetPresenter, call the get() method on the provider :

MyWidgetPresenter myWidgetPresenter = myWidgetPresenterProvider.get();
like image 71
jdramaix Avatar answered Jan 25 '26 17:01

jdramaix