struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matihost <>
Subject Re: Can I access a constant in a Freemarker view?
Date Mon, 24 Dec 2007 10:29:15 GMT
> 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?

I don't know if it is the best solution, but you have access to OGNL from Freemarker view.

So for example:

<#if someVariable = stack.findValue('@class.package.ClassName@CONSTANT_NAME')>

<#-- Some code -->


and it works in my tags.
If you need access to static methods from OGNL you will need to set probably struts property
'struts.ognl.allowStaticMethodAccess' to true.

Mateusz Nowakowski

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message