mercredi 27 mai 2015

Spring MVC send all model classes as json string

I'm a noob to Spring MVC and JSON. I have a class hierarchy (interface, classes, subclasses) that I want to send across to my view and then resurrect the objects in the view (perhaps some Json library, currently using FlexJson).

The idea behind this is I'm trying to generate a toolbox depending on the classes in my configuration hierarchy, allowing users to create a system by dragging and dropping (using jQuery?) the items (types from configuration hierarchy), setting various attributes (properties) on each of those items, and eventually saving and sending the configuration back to be persisted.

So far...I've only got as far as harvesting the (sub)types (of objects) from the package using [Reflections Library](http://ift.tt/Ofz26b) as thus:

Reflections reflections = new Reflections( new ConfigurationBuilder()
            .setUrls( ClasspathHelper.forPackage( "com.obsm.myapp.model.configuration" ) )
            .setScanners( new SubTypesScanner(false) )
            .filterInputsBy( new FilterBuilder().includePackage( "com.obsm.myapp.model.configuration" ) ) );
    Set<Class<?>> types = reflections.getSubTypesOf( Object.class );

Any help is much appreciated.





Aucun commentaire:

Enregistrer un commentaire