I think you're code to set the id is running before there is any DOM peer
yet. When I've needed to access a widget's element, I've usually done it
in an attach handler, or in a method that I know won't get invoked until
the widget has been attached to the DOM.
On Wednesday, October 9, 2013 10:12:46 AM UTC-4, Steen Lillethorup
Frederiksen wrote:
>
> I am trying to create a generic Composite widget, using Java Generics.
> However I keep getting the assertion error:
>
> java.lang.AssertionError: This UIObject's element is not set; you may be
> missing a call to either Composite.initWidget() or UIObject.setElement()
>
>
> I have defined my Composite widget as follows:
>
> public class DataEntry<DataType extends FocusWidget> extends Composite {
>
> final protected FlowPanel panel;
> final protected InlineLabel promptLabel;
> final protected DataType inputElement;
>
> public DataEntry(final DataType inputField, final String guiId, final
> String prompt) {
> super();
>
> promptLabel = new InlineLabel(prompt);
> inputElement = inputField;
>
> panel = new FlowPanel();
> panel.add(promptLabel);
> panel.add(inputField);
> initWidget(panel);
>
> getElement().setId(guiId);
> promptLabel.setStylePrimaryName("dio-DataEntry-Prompt");
> inputElement.setStylePrimaryName("dio-DataEntry-Input");
> }
>
> And I am defining my concrete Composite widgets as follows (could be
> TextBox, TextArea etc.):
>
> public class ListEntry extends DataEntry<ListBox> {
> public ListEntry(String guiId, String prompt) {
> super(new ListBox(), guiId, prompt);
> }
> ...
> }
>
> Can anyone explain to me, what I have missed here?
>
> Thanx
> Steen
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.