Subscribe

Camel case Java variables and freemarker.

  1. 2011-11-23 11:55:12 PST
    Hello, I am usign freemarker(2.3.18) to access variables within a custom java class, and find that it has trouble picking up variables with camel case. My class structure is: public class Student{ private String name_last, nameFirst; public String getName_last(){ return name_last; } public String getNameFirst(){ return nameFirst; } } When i try to access them in my freemarker template, ${passedInStudent.name_last} returns just fine, but when i try to access ${passedInStudent.nameFirst}, i get an error saying passedInStudent.nameFirst is undefined. Is there something wrong with the way I am accessing these variables? Is this a known problem in freemarker? thanks in advance for the help. -VSP
  2. 2011-11-23 22:21:14 PST
    If you getting error as "undefined" then it indicates that "passedInStudent.nameFirst" is null .... please make sure "passedInStudent.nameFirst" is not null . refer the below link for handling null check inm ftl's : http://freemarker.sourceforge.net/docs/app_faq.html#faq_null
Jump To:
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.