Fotinopoulos Giorgos
Fotinopoulos Giorgos

Reputation: 1027

UiBinder custom widget with parameterized constructor

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>

Upvotes: 10

Views: 11695

Answers (1)

Peter Knego
Peter Knego

Reputation: 80340

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

Upvotes: 10

Related Questions