UiBinder custom widget with parameterized constructor

11,581

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

Share:
11,581
Fotinopoulos Giorgos
Author by

Fotinopoulos Giorgos

Updated on June 04, 2022

Comments

  • Fotinopoulos Giorgos
    Fotinopoulos Giorgos almost 2 years

    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>
    
  • Fotinopoulos Giorgos
    Fotinopoulos Giorgos almost 13 years
    First of all thanks, that was the solution. But why it is not possible to add the @Uiconstructor in several constructors (overloading) ? Then how the gwt widgets offer in uibinder several arguments to pass at declaration not strictly all?
  • Fotinopoulos Giorgos
    Fotinopoulos Giorgos almost 13 years
    I mean i can declare <g:VerticalPanel width="120"> and <g:VerticalPanel width="120" height="100"> but with the @UiConstructor i have to add ALL the arguments.