Re-initializing a widget...

Hi all,

I have a problem with regards to
re-initializing
Widgets.

I have my custom widget which draws a line graph.
I have successfully created the application class, the server-side component, the vaadin integration widget & the actual GWT widget.

The very first time the GWT widget is called
(the super() call from vaadin integration widget)
, it’s initialized normally.
But when I try to re-initialize the widget using
initWidget(Widget widget)
, it gives me a
IllegalStateException
saying that
“Composite.initWidget() may only be called once”
.

The reason for this is that the
Widget object on the level of Composite is not null
. Is there a way to set the
Composite.widget to NULL
?

Any help is greatly appreciated.

Thanks in advance,
Asela.

PS:
I tried setWidget(null) & it internally refers to initWidget(). So that’s out :frowning:

Hi!

I would probably avoid trying to subvert restrictions in GWT. You might very well break something that you never thought of and cause all kinds of nasty bugs that aren’t visible at first.

If you have a widget that is expensive to construct, you could try to break out the expensive operations to a different class that can be re-used for different instances of your widget. That would probably, if I understood you correctly, do what you want while conforming to the restrictions in GWT.

HTH,
/Jonatan