Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UiBinder custom widget with parameterized constructor

Tags:

gwt

uibinder

Let's say we have a custom widget that was declared using UiBinder and it needs to have some arguments in its constructor. How can I make it in order to be able to supply these arguments when i declare it in ui.xml?

That is i have a

CustomWidget(int param1, int param2)

and when i add it to a ui.xml i need to be able to do:

...

xmlns:my="urn:import:...">

<g:Container>
 <my:CustomWidget param1="1" param2="arg2"/>
</g:Container>
like image 442
Fotinopoulos Giorgos Avatar asked Jul 20 '11 09:07

Fotinopoulos Giorgos


1 Answers

Use @UiConstructor on your constructor:

@UiConstructor
CustomWidget(int param1, int param2)

Look at docs: http://code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html#Using_a_widget

like image 74
Peter Knego Avatar answered Oct 28 '22 08:10

Peter Knego