Elemental2 and widgets

642 views
Skip to first unread message

Gordan Krešić

unread,
Jun 17, 2020, 5:56:46 AM6/17/20
to GWT Users
What would be the best way to start migrating large widget-based app to
elemental2? I suppose it should start with leaf widgets and then progress up
the widget hierarchy tree until RootPanel itself is replaced with
elemental2.dom.HTMLElement-derivative, but I can't find a way to even start
mixing elemental2 with widgets.

For example, how would one pass org.dominokit.domino.ui.grid.GridLayout as
param to com.google.gwt.user.client.ui.AcceptsOneWidget.setWidget(IsWidget)?

My google-fu gives me only old samples which references (now removed)
org.jboss.elemento.Elements.asWidget.

Environment:

GWT 2.9.0
elemental2 1.0.0
elemento 1.0.0

-gkresic.

Jens

unread,
Jun 17, 2020, 7:35:18 AM6/17/20
to GWT Users
Something like (totally untested) might work:

class WidgetAdapter extends Widget {

 
WidgetAdapter(elemental2.dom.Element element) {
    setElement
(Js.<com.google.gwt.dom.client.Element>uncheckedCast(element));
 
}

}


But keep in mind that GWT widgets have been rewritten to be J2CL compatible (they use jsinterop internally now and in the future might be changed to use elemental2 dom elements). So it is not an urgent need to switch, unless you really want to.

-- J.

Frank Hossfeld

unread,
Jun 17, 2020, 8:46:30 AM6/17/20
to GWT Users
Please take a look here: https://gitter.im/hal/elemento for more information and here: https://github.com/hal/elemento/issues/82

Gordan Krešić

unread,
Jun 17, 2020, 11:39:46 AM6/17/20
to google-we...@googlegroups.com
On 17. 06. 2020. 13:35, Jens wrote:
>
> But keep in mind that GWT widgets have been rewritten to be J2CL compatible
> (they use jsinterop internally now and in the future might be changed to use
> elemental2 dom elements). So it is not an urgent need to switch, unless you
> really want to.

Nice to hear that widgets are still maintained.

However, it's not that I'm migrating away from GWT widgets, it's more
migration to a more modern (by look and feel) widgetset (like Domino UI).

-gkresic.

Gordan Krešić

unread,
Jun 17, 2020, 11:44:59 AM6/17/20
to google-we...@googlegroups.com
On 17. 06. 2020. 14:46, Frank Hossfeld wrote:
> Please take a look here: https://gitter.im/hal/elemento for more information
> and here: https://github.com/hal/elemento/issues/82

I've found elemento-widget before, but wasn't sure if it's still relevant.
This commit says it's abandoned:

https://github.com/hal/elemento/blob/47d59fe225370af38facd1d0c2924275f8850d9a/CHANGES.md#deprecations

-gkresic.

Vegegoku

unread,
Jun 20, 2020, 6:55:20 AM6/20/20
to GWT Users
That will do the required wiring to make elements behave like widgets, it will not wire events correctly nor it will wire the attach/detach, you can do it but it is not a simple task, thats why elemento moved the issue the lib user instead of solving it in the lib itself.

Vegegoku

unread,
Jun 21, 2020, 2:55:41 AM6/21/20
to GWT Users
sorry, i meant to say : That will NOT do the required wiring

Gordan Krešić

unread,
Jun 21, 2020, 7:02:09 AM6/21/20
to google-we...@googlegroups.com
On 21. 06. 2020. 08:55, Vegegoku wrote:
> sorry, i meant to say : That will *NOT* do the required wiring
Could you be a bit more specific?

So far, I've tested with only a very simple hierarchy:

RootPanel -> SimpleLayoutPanel -> [widget/Domino border] -> GridLayout ->
other Domino elements

and I didn't see any problems, neither with event handling (click listeners
on GridLayout children) nor with GridLayout.onDetached (didn't test onAttached).

So, where I can expect problems to start manifesting?

Also, back to my initial question: ss there any "best practice" for
graduately migrating widget-based app to DominoUI?

-gkresic.

Jens

unread,
Jun 22, 2020, 3:35:19 AM6/22/20
to GWT Users


So, where I can expect problems to start manifesting?

I think if you can make sure that you only put elemental2 based components into GWT widgets, then it should work without major issues. But if you have to add a GWT widget into an elemental2 based component, then you have the problem of handling the widget lifecycle correctly so that event handlers for that GWT widget work correctly.


-- J.

Vegegoku

unread,
Jun 26, 2020, 10:40:33 AM6/26/20
to GWT Users
in most of the simple cases where you just wrap an element inside a widget like that, then you keep using the element as element not as a widget, things should work, but if you at some point needs a widget like interaction between wrapped widgets where the widget will expect a correct wiring of parent widget and a proper events sink you will face problems.

as for domino-ui, i would say you can just wrap as widgets only to append those domino-ui as elements, which means you will only treat them as widgets when you are appending them. other than that the gradual migration depends on how you would map your widgets to the domino-ui components, and how you split your views, and what mvp you use for example.
Reply all
Reply to author
Forward
0 new messages