• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to correctly access attributes of list member in FreeMaker

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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]
 
    Bookmark Topic Watch Topic
  • New Topic