collections

24 views
Skip to first unread message

Robert J. Carr

unread,
Jan 7, 2014, 7:42:25 PM1/7/14
to gwtex...@googlegroups.com
I've been running some tests using the gwt-exporter and I'm getting most everything working that I need to.  My hurdle right now is the exporting of collections (i.e., methods with collections as parameters or return types).  I can somewhat easily transfer all of my lists to arrays but this is going to be much harder where I use map types.

Is there a technical reason why the collections don't work?  Is it a feature that is being planned?  Are there any work arounds I could consider?

Thanks-
Robert

Manuel Carrasco Moñino

unread,
Jan 8, 2014, 2:20:30 AM1/8/14
to gwtex...@googlegroups.com
We use always arrays because it is the normal way to use lists in javascript. 

Of course we could support collections or lists, but it implies extra work and that is not a very demanded feature but we are opened to any contribution.

The workaround is to use extra java methods in your java classes to deal with them, ie:

List<Object> myRealMethod(Collection<Exportable> params)
you have to write a method with the signature 
Object[] myExportMethod(Exportable[] params)

If you have a class which you cannot or dont want to modify, you can use an overlay class with those extra methods to export the class.


- Manolo



--
Has recibido este mensaje porque estás suscrito al grupo "gwtexporter" de Grupos de Google.
Para anular la suscripción a este grupo y dejar de recibir sus correos electrónicos, envía un correo electrónico a gwtexporter...@googlegroups.com.
Para obtener más opciones, visita https://groups.google.com/groups/opt_out.

Robert J. Carr

unread,
Jan 8, 2014, 12:29:29 PM1/8/14
to gwtex...@googlegroups.com
Hi Manolo-

Thanks for the response.  As I said, I can change my collection lists to arrays without too much difficulty, but what do I do for collection mappings?  Any suggestions?

Thanks!

Manuel Carrasco Moñino

unread,
Jan 9, 2014, 4:25:10 AM1/9/14
to gwtex...@googlegroups.com
On Wed, Jan 8, 2014 at 6:29 PM, Robert J. Carr <rjc...@gmail.com> wrote:
Hi Manolo-

Thanks for the response.  As I said, I can change my collection lists to arrays without too much difficulty, but what do I do for collection mappings?  Any suggestions?


I would use an exportable wrapper around the map, basically a bean with an array for keys and another array for values, in this way gwt-exporter would take care about key/value types and export them in the appropriate way, then you could use getter/setter in javascript for using it.

Another option is to wrap your map using pure javascript maps.

- Manolo.

Robert J. Carr

unread,
Jan 9, 2014, 6:06:15 PM1/9/14
to gwtex...@googlegroups.com
OK, thanks Manolo!

And just curious, I've been writing java for about 15 years and been using GWT for about 7 I think (since the *very* early days) but I've never written a library like this.  If I wanted to try and augment gwt-exporter to support java originated collections (lists and maps with generics), how long do you think it'd take?  Or, to put another way, let me know how long you think it'd take you, and I'll probably double or triple that estimate. :)

Thanks-
Robert



--
Has recibido este mensaje porque estás suscrito a un tema del grupo "gwtexporter" de Grupos de Google.
Para anular la suscripción a este tema, visita https://groups.google.com/d/topic/gwtexporter/9VRc2r5EgB8/unsubscribe. Para anular la suscripción a este grupo y todos sus temas, envía un correo electrónico a gwtexporter...@googlegroups.com.

Manuel Carrasco Moñino

unread,
Jan 10, 2014, 3:26:25 AM1/10/14
to gwtex...@googlegroups.com
On Fri, Jan 10, 2014 at 12:06 AM, Robert J. Carr <rjc...@gmail.com> wrote:
OK, thanks Manolo!

And just curious, I've been writing java for about 15 years and been using GWT for about 7 I think (since the *very* early days) but I've never written a library like this.  If I wanted to try and augment gwt-exporter to support java originated collections (lists and maps with generics), how long do you think it'd take?  Or, to put another way, let me know how long you think it'd take you, and I'll probably double or triple that estimate. :)

If I only did that task, it might take me  1 or 2 days including test units and some refactoring. 
If you decide go ahead with it, your contribution is welcome.

- Manolo

Robert J. Carr

unread,
Jan 10, 2014, 2:17:58 PM1/10/14
to gwtex...@googlegroups.com
Hi Manolo-

I took a look at the code yesterday and I think I need to multiply your estimate by about 10x. :)

So, I'll probably find a work around instead, or not use the library, but thanks for your time.  If I do happen to make changes I'll be sure to let you know.

Robert

Reply all
Reply to author
Forward
0 new messages