Home Grails 3.2.5 Json view template not used with expand?
Reply: 0

Grails 3.2.5 Json view template not used with expand?

Jay
1#
Jay Published in 2018-01-09 10:03:57Z

A simple example domain class Comment has an associated class 'Text text'.

class Comment {
    String name
    Text text
}

A json view template "_comment.gson":

model {
     Comment comment
}

json g.render(comment) {
    desc "from template"
}

Invocation list.gson. Uses template - output has "desc" property.

model {
    Iterable<Comment> comments
}

json g.render(comments)

Invocation via list.gson. Does not use template - text expanded but no "desc" property in output.

model {
    Iterable<Comment> comments
}

json g.render(comments, [expand:['text']])

In short, the use of 'expand' suppresses the use of the comment template. Is this expected, and how to work around it?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.294137 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO