1

Suppose Author belongs_to Boook. Is it possible to do the same as in Rails templates in a Freemarker template:

"author": ${book.author.last_name}

I tried without success. May be my syntax is wrong or I'm missing something ?

belgoros
  • 3,590
  • 7
  • 38
  • 76

1 Answers1

1

You would need to use the include() and pre-load objects for this. Please, see: http://javalite.io/lazy_and_eager#eager-simultaneous-loading-of-parents-and-children

You would need to experiment with code a little. In the worst case, you can add a method to a model and call that from a template.

ipolevoy
  • 5,432
  • 2
  • 31
  • 46
  • OK, depending on use or not `include`, I create getter/setter for the needed model attribute. Thank you. – belgoros Sep 26 '18 at 15:16