A Short Intro Article to JsInterop "Native"

234 views
Skip to first unread message

lofid...@gmail.com

unread,
Sep 9, 2020, 10:59:13 AM9/9/20
to GWT Users

Hi All,

I wrote a short introduction for JsInterop "native" with a simple Calculator and CalculatorService: https://bit.ly/WebBrowserGWTJsInteropNative

Enjoy 😊

Lofi

Craig Mitchell

unread,
Sep 11, 2020, 11:13:20 PM9/11/20
to GWT Users
Thanks Lofi.  I have been using JSNI, and wanted a quick intro into JsInterop.  Your article was perfect.  Very well written.

lofid...@gmail.com

unread,
Sep 12, 2020, 5:31:02 AM9/12/20
to GWT Users
Great to hear that the article helps you! 

I'm planing to write following short introduction:
- The next one would be handling the work with Elemental2 - this is the foundation
- Showing Dependency Injection and all standard mechanism (patterns in Java, Mock objects, etc.)  which we use daily in Java.
- Maybe Elemento, because some UI frameworks use this as foundation
- Then going down to all those nice UI frameworks like Domino, DnComponents, VueGWT, React4J, PatternFly4Java, GWTBootstrap3, GWT MaterialDesign... Also with Nalu... 

So a lot of to write 😂IMHO GWT / J2CL is very good if you are coming from Java, eco system, tooling, language for the whole layer. As a Java developer I have everything, so no need to go to TypeScript and JS...

Stay tuned 😉

Guillen Antonio

unread,
Sep 13, 2020, 4:28:54 AM9/13/20
to google-we...@googlegroups.com
Thanks for this article, I come from Java and C++ world and I am using GWT for first time. I need to use GoJS in my architecture and I think that your post will help me. Very good explanation.
Antonio

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/89b888b5-0f6d-4c5f-8bfe-f5a9a4471f94n%40googlegroups.com.

lofid...@gmail.com

unread,
Sep 15, 2020, 3:42:49 AM9/15/20
to GWT Users
Thanks for the comment!

Before you create manually the JsInterop files from GoJS, you should take a look the two JsInterop Generators available which I've shown in my new article 

"Using IndexedDB in Web Browser — All in Java with Mrs. Gwitany and Dr. Jackl"  

Thanks,
Lofi

Guillen Antonio

unread,
Sep 15, 2020, 4:18:35 PM9/15/20
to google-we...@googlegroups.com
Hi all, 
I am looking for a way to add the html page containing my GoJs functions in a Panel widget how can i do this?
Examples?
Thanks a lot

lofid...@gmail.com

unread,
Sep 16, 2020, 3:37:17 AM9/16/20
to GWT Users
You could take a look at this video, very nice intro how to integrate JavaScript lib with the help of JsInterop: 


Hope this helps,
Lofi

lofid...@gmail.com

unread,
Sep 16, 2020, 3:57:04 AM9/16/20
to GWT Users
... BTW I think it is important that you inject the GoJS with http://www.gwtproject.org/javadoc/latest/com/google/gwt/core/client/ScriptInjector.html

so that it is available when you run your app...

Or you just take a look at Charba which intergrate ChartJS for GWT and J2CL: https://github.com/pepstock-org/Charba 

Hope this helps.

Andrea Stocchero

unread,
Sep 24, 2020, 4:04:48 AM9/24/20
to GWT Users
Thanks a lot Lofi for mentioning  https://github.com/pepstock-org/Charba .

Let me outline that the injection of javascript code could also be done putting the script element into html page of the application.
In my opinion it depends on the goal of GoJS wrapping, if the goal is to create a lib (like Charba is for CHARTJS) then the injection should be done by GWT, otherwise if the use case is "I need to use GoJS for my application", then maybe the ScriptInjector is not needed. In last case you must have the full application control in order to avoid exceptions due to a misalignment between JSINTEROP mapping and the version of javascript library.

In Charba we are not using the ScriptInjector because is more a J2CL lib (without any dependency with GWT) than a GWT one, and we are creating and adding a script element injecting the javascript code.
Instead, if the platform is only GWT, it could be also helpful to go to ClientBundle to inject the javascript code, in order to leverage on code splitting if needed.

A lesson learned developing Charba is also that sometimes is quite difficult (I don't want to say impossible) to map all javascript code, for many reasons. Therefore some javascript code could be needed, wrapped by a custom JsType native.
Reply all
Reply to author
Forward
0 new messages