You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Gary Affonso <gl...@greywether.com> on 2007/12/23 23:22:18 UTC

Can I access a constant in a Freemarker view?

I've got an object that I expose to my view via getModel.  That object 
has a typical "public static final" constant...

   public static final String firstName_KEY = "firstName";

Note that I purposefully don't provide a static getter (I don't want to 
have to write getters for all my constants).

Can I access that from my FreeMarker view?

Checking the source it looks like objects are wrapped using a custom 
subclass of BeansWrapper.  But it doesn't seem to do anything special 
with regard to constants.

And a brief perusal of the Freemarker docs seems to imply that "public 
static constants" are not exposed to the template by the BeansWrapper 
superclass.

So I'm thinking the answer is no (without some more work).  But I wanted 
to do a quick ping of the list in the hope that I'm missing something. 
(Like maybe a nifty built-in?)

Thanks!

- Gary

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org