This is a migrated thread and some comments may be shown as answers.

Why does ListView JSP tag serialize entire data object?

3 Answers 35 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Jane
Top achievements
Rank 1
Jane asked on 13 Jan 2017, 06:34 AM

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)

3 Answers, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 16 Jan 2017, 02:47 PM
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.
0
Jane
Top achievements
Rank 1
answered on 17 Jan 2017, 03:55 AM
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. 
0
Alex Hajigeorgieva
Telerik team
answered on 18 Jan 2017, 03:40 PM
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 (charts) and form elements.
Tags
ListView
Asked by
Jane
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Jane
Top achievements
Rank 1
Share this question
or