Hi all,

I'm new to Freemarker on Spring. Am currently using Spring 2.5.6 and Freemarker 2.3.15.

I'm trying to control the visibility of UI elements on a view based on whether the user is logged in and what roles they might have. I can't seem to get access to the HttpServletRequest (more specifically HttpServletRequest.getRemoteUser() or HttpServletRequest.getUserPrincipal()) in the ftl template.

I know the FreeMarkerView exposes the RequestContext object by default as ${springMacroRequestContext}, but this class doesn't expose the two methods above, though it has other useful methods exposed (like getContextPath and getRequestUri).

Also, I'm aware of ${Request} which is a HttpRequestHashModel and ${RequestParameters} which is a HttpRequestParametersHashModel, but neither allow me to access the underlying HttpServletRequest instance.

Oh, and ${Request.request.remoteUser} doesn't work.

I was wondering what is the best way of doing this? Should I extend FreeMarkerView and implement something custom in exposeHelpers() or should I extend RequestContext and expose these methods?

Any help or pointers in the right direction is much appreciated.

thanks,
dave