Hi Jens

Thanx for your answer.

Below I have attached the stack trace.
Furthermore, I was wrong in my assumption, that the ListEntry class caused 
the problem - it is actually another class, that causes the problem. 
Another class, still deriving from the DataEntry class - the DualListEntry 
class.

java.lang.AssertionError: This UIObject's element is not set; you may be 
missing a call to either Composite.initWidget() or UIObject.setElement() at 
com.google.gwt.user.client.ui.UIObject.getElement(UIObject.java:556) at 
com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:94) at 
com.google.gwt.user.client.ui.FlowPanel.add(FlowPanel.java:44) at 
dk.dbc.dataio.gui.client.components.DataEntry.<init>(DataEntry.java:28) at 
dk.dbc.dataio.gui.client.components.DualListEntry.<init>(DualListEntry.java:15) 
at 
dk.dbc.dataio.gui.client.views.FlowCreateViewImpl.<init>(FlowCreateViewImpl.java:48)
 
at 
dk.dbc.dataio.gui.util.ClientFactoryImpl.<init>(ClientFactoryImpl.java:22) at 
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
 
at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 
at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at 
com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:475) at 
com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49) at 
com.google.gwt.core.shared.GWT.create(GWT.java:57) at 
com.google.gwt.core.client.GWT.create(GWT.java:85) at 
dk.dbc.dataio.gui.client.MainEntryPoint.<init>(MainEntryPoint.java:18) at 
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
 
at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 
at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at 
com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:475) at 
com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:385) at 
com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
 
at 
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
 
at 
com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
 
at java.lang.Thread.run(Thread.java:722)

The DualListEntry class is not (as the ListBox, TextBox etc. that I also 
use to construct ListBoxEntry, TextBoxEntry etc.) a standard GWT widget, 
but my own widget. It looks something like this:

public class DualList extends FocusWidget {
    
    HorizontalPanel container = new HorizontalPanel();
    ListBox right = new ListBox(true);
    ListBox left = new ListBox(true);
    Button addItem = new Button(">");
    Button removeItem = new Button("<");
    VerticalPanel buttonPanel = new VerticalPanel();

    public DualList() {
        container.setStylePrimaryName(dio-DualList);
        addItem.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                moveItems(left, right);
            }
        });
        removeItem.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                moveItems(right, left);
            }
        });
        buttonPanel.add(addItem);
        buttonPanel.add(removeItem);
        container.add(left);
        container.add(buttonPanel);
        container.add(right);
    }

    public void addAvailableItem(String value, String key) {
        ...
    }

    public void setAvailableItems(Collection<? extends Entry<String, 
String>> items) {
        ...
    }

    ...
}

Originally, the DualList class inherited from Composite rather that 
FocusWidget - however, in order to use the DualList together with 
DataEntry, I had to extend it from FocusWidget.
And I think, that the problem is related to this somehow...

Br
Steen

Den onsdag den 9. oktober 2013 16.12.46 UTC+2 skrev Steen Lillethorup 
Frederiksen:
>
> 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.

Reply via email to