• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

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]
 
Our first order of business must be this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic