I'm experiencing some problems adding a SuggestBox
to my application. The UiBinder
template looks like:
...
<g:FlowPanel>
<g:SuggestBox ui:field='actorSuggestBox' styleName='{style.givemespace}' />
<g:Button ui:field="addActorButton">Add Actor</g:Button>
</g:FlowPanel>
<g:FlexTable ui:field='actorsTable'></g:FlexTable>
....
and I am creating my own suggestBox by extending MultiWordSuggestOracle
. I have debugged my code and made sure that the custom SuggestBox
class gets created and initialized properly before I initialize the UiBinder
.
My SuggestBox
doesn't work well. What puzzles me is that if I add it to the FlexTable
(that I had to show entries I was adding via the suggestbox) using setWidget(row, column, widget)
this component works properly, so probably I am missing something when initializing the UI. Although I have Dewsbury' book on GWT app, it does not cover UiBinder
. The tutorials and code examples I have checked use
<g:SuggestBox ui:field="mySuggestBox"/>
with no problem. Yet, I don't understand what I'm doing wrong when creating and initializing this component or the UI that makes the SuggestBox
not to work. I don't know if it takes more than
actorSuggestBox = new SuggestBox(new CustomSuggestOracle());
to initialize the sugestbox or if there is any other important concept that I am missing when linking/initializing this component.
The component is declared as
@UiField
@Ignore
SuggestBox actorSuggestBox;
You have to use:
@UiField (provided = true)
SuggestBox actorSuggestBox = new SuggestBox(new CustomSuggestOracle());
You need to initialize this widget before you call the binder (createAndBindUi
).