Why does ListView JSP tag serialize entire data object?

4 posts, 0 answers
  1. Jane
    Jane avatar
    15 posts
    Member since:
    Oct 2016

    Posted 13 Jan Link to this post

    The ListViewTag class serialises the entire data object, even if those fields aren't used in the ListView.  I'm using a Hibernate entity which uses a list of objects from a many-to-many relationship and I only want to retrieve these when I need them.  When the Serializer class tries to serialise the  object then Hibernate tries to populate the list but it can't because there is no database session open.

    Is there any way fields can be ignored by the com.kendoui.taglib.json.Serializer?

    See stack trace:

    org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.syngenta.combichem.model.CcwEnumeration.buildingBlocks, could not initialize proxy - no Session
        org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:575)
        org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:214)
        org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:554)
        org.hibernate.collection.internal.AbstractPersistentCollection.read(AbstractPersistentCollection.java:142)
        org.hibernate.collection.internal.PersistentSet.iterator(PersistentSet.java:180)
        com.kendoui.taglib.json.Serializer.serializeIterable(Serializer.java:171)
        com.kendoui.taglib.json.Serializer.serialize(Serializer.java:109)
        com.kendoui.taglib.json.Serializer.serializeMap(Serializer.java:158)
        com.kendoui.taglib.json.Serializer.serialize(Serializer.java:121)
        com.kendoui.taglib.json.Serializer.serializeIterable(Serializer.java:174)
        com.kendoui.taglib.json.Serializer.serialize(Serializer.java:109)
        com.kendoui.taglib.json.Serializer.serializeMap(Serializer.java:158)
        com.kendoui.taglib.json.Serializer.serialize(Serializer.java:113)
        com.kendoui.taglib.json.Serializer.serializeMap(Serializer.java:158)
        com.kendoui.taglib.json.Serializer.serialize(Serializer.java:111)
        com.kendoui.taglib.WidgetTag.script(WidgetTag.java:101)
        com.kendoui.taglib.WidgetTag.doEndTag(WidgetTag.java:61)
        com.kendoui.taglib.ListViewTag.doEndTag(ListViewTag.java:82)
  2. Alex Hajigeorgieva
    Admin
    Alex Hajigeorgieva avatar
    269 posts

    Posted 16 Jan Link to this post

    Hi Jane,

    Unfortunately, the Serializer class does not afford such functionality of skipping properties. You can check the source code which serialises at:

    https://github.com/telerik/kendo-ui-core/blob/a2c7ec547302c4741103f1f1bb034b57eb201f45/wrappers/java/kendo-taglib/src/main/java/com/kendoui/taglib/json/Serializer.java#L97

    One way to go around this could be to create a ViewModel (or in your case a couple of ViewModels) which includes the required properties only.

    I hope this helps.

    Kind Regards,
    Alex Hajigeorgieva
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualisation (charts) and form elements.
  3. Jane
    Jane avatar
    15 posts
    Member since:
    Oct 2016

    Posted 16 Jan in reply to Alex Hajigeorgieva Link to this post

    Thanks Alex, we found another workaround.  The Jackson JSON library has an annotation which can be used  so that it's deserializer ignores missing fields.  A similar annotation would be useful for the Kendo Serializer to ignore certain fields. 
  4. Alex Hajigeorgieva
    Admin
    Alex Hajigeorgieva avatar
    269 posts

    Posted 18 Jan Link to this post

    Hello Jane,

    Thank you very much for getting back to share your solution here.

    It seems like it would be a useful enhancement of the JSP wrappers Serializer.

    We care what our clients have to say and record the popularity of new ideas in our UserVoice portal. Ideas which get upvoted the most are reviewed by the team and prioritised for future development.

    The Kendo UI JSP ideas section is available at:

    http://kendoui-feedback.telerik.com/forums/127393-kendo-ui-feedback/category/63709-jsp-wrappers

    Kind Regards,
    Alex Hajigeorgieva
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top