1

Is it possible to use the Elemental collections (elemental.util.Collections, elemental.util.ArrayOfInt, elemental.util.MapFromStringTo, etc) in a non-elemental GWT app. I'm using these modules already:

<!-- Inherit the core Web Toolkit stuff.                        -->
<inherits name='com.google.gwt.user.User' />

<!-- Inherit the RequestBuilder stuff.                        -->
<inherits name="com.google.gwt.http.HTTP" />


<!--  Inherit GQuery -->
<inherits name='com.google.gwt.query.Query' />

But I'd like to start using the lightweight Elemental collections rather than Java ArrayList and HashMap. Is that possible? Would it be fairly easy to port from Elemental into it's own module for this purpose? Thanks for you help.

appbootup
  • 9,537
  • 3
  • 33
  • 65
Ezward
  • 17,327
  • 6
  • 24
  • 32
  • FYI, we'll split JSON and collections out of Elemental into their own modules. This should hopefully ship in GWT 2.6 later this year. – Thomas Broyer Feb 15 '13 at 10:10

2 Answers2

4

Sure, all you have to do is include the following declaration in your module descriptor (*.gwt.xml):

<inherits name="elemental.Elemental"/>

See the elemental example on the GWT trunk.

Eliran Malka
  • 15,821
  • 6
  • 77
  • 100
0

I could not get the GWT Elemental projects silvercomet or simple to execute in FireFox.

However a below simple elemental test code executes in FireFox and Chrome along with gwt user and http modules.

Module File.

<module rename-to="HelloElemental">
    <inherits name="elemental.Elemental" />
    <!-- Inherit the core Web Toolkit stuff. -->
    <inherits name='com.google.gwt.user.User' />
    <!-- Inherit the RequestBuilder stuff. -->
    <inherits name="com.google.gwt.http.HTTP" />
    <add-linker name="xsiframe" />
    <set-configuration-property name="devModeRedirectEnabled" value="true" />
    <entry-point class="com.google.silvercomet.client.Main" />
</module>

Entry Point Class -

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;

import elemental.util.ArrayOf;
import elemental.util.Collections;

public class Main implements EntryPoint
{
    public void onModuleLoad()
    {
        ArrayOf<String> items = Collections.arrayOf();
        items.insert( 0, "First" );
        Window.alert( items.get( 0 ) );
    }
}
appbootup
  • 9,537
  • 3
  • 33
  • 65