• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to correctly access attributes of list member in FreeMaker

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I tried to implement a module for logging certain user operations. I defined a class Log as shown below:



A collection of such log entries are collected in order to list them in a web page. I defined a template file oplog_list.htm in reference to other template file. However, it's very stange that I can not use ${log.LogID} in the template file. At runtime, this error will appear:


Expression log.LogID is undefined on line 21, column 54 in default/admin/oplog_list.htm. The problematic instruction: ---------- ==> ${log.LogID} [on line 21, column 52 in default/admin/oplog_list.htm] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression log.LogID is undefined on line 21, column 54 in default/admin/oplog_list.htm. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124) at



I spent the whole afternoon in debugging this error but in vain. Could any one of you kindly help me out?

Help! Help! Please!
Michael Wu



[originally posted on jforum.net by michaelwu]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hhm.. Try using



Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It works. Thanks. (I thought FreeMaker uses Java Reflection api to access object/bean data member implicitly because JForum's template files does not have the get method calls. Strange!)

Michael Wu
[originally posted on jforum.net by michaelwu]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It does, but I don't know exactly why it fails sometimes.

Rafael
[originally posted on jforum.net by Rafael Steil]
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic