Daniel Dekany
2014-10-31 19:30:53 UTC
Currently there's no published API to capture those calls. So the best
you can do is what you did. Of course it can break in any future
FreeMarker releases... so at least add a runtime check that you are
actually overriding that method, and give an explanation error message
if you don't. I add to my TODO considering a such feature, but that's
the best I can do for now.
As of Spring, I have no experience with Spring+FreeMarker, but maybe
it sets the beans wrapper itself in FreeMarkerConfigurer and
overwrites you setting. It should work otherwise.
you can do is what you did. Of course it can break in any future
FreeMarker releases... so at least add a runtime check that you are
actually overriding that method, and give an explanation error message
if you don't. I add to my TODO considering a such feature, but that's
the best I can do for now.
As of Spring, I have no experience with Spring+FreeMarker, but maybe
it sets the beans wrapper itself in FreeMarkerConfigurer and
overwrites you setting. It should work otherwise.
Hi falks,
I'm developing project where I use freemarker. There is need to
intercept method invocation in BeansWrapper namely 'invokeMethod'.
TemplateModel invokeMethod(Object object, Method method, Object[] args)
This method has private-package access level. I looked into source but
didn't find a way how i can intercept this method. I need to know which
fileds of my domain object are called on ftls. I need to generate log
ftl name: 'user.ftl' uses ''com.github.User' class and invokes next
methods: 'getName' and etc.
Please could you help me? I use spring+freemarker
I tried register my own BeansWrapper
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigu
rer">>I'm developing project where I use freemarker. There is need to
intercept method invocation in BeansWrapper namely 'invokeMethod'.
TemplateModel invokeMethod(Object object, Method method, Object[] args)
This method has private-package access level. I looked into source but
didn't find a way how i can intercept this method. I need to know which
fileds of my domain object are called on ftls. I need to generate log
ftl name: 'user.ftl' uses ''com.github.User' class and invokes next
methods: 'getName' and etc.
Please could you help me? I use spring+freemarker
I tried register my own BeansWrapper
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigu
<property name="templateLoaderPath" value="/WEB-INF/ftl/"/>
<property name="freemarkerSettings">
<props>
<prop
key="object_wrapper">freemarker.ext.beans.InterceptBeansWrapper</prop>
</props>
</property>
</bean>
but see that in BeanModel
retval = wrapper.invokeMethod(object, pd.getReadMethod(), null);
wrapper is instance of freemarker.ext.beans.BeansWrapper but not my
InterceptBeansWrapper
Could you give me advice ?
Thanks
<property name="freemarkerSettings">
<props>
<prop
key="object_wrapper">freemarker.ext.beans.InterceptBeansWrapper</prop>
</props>
</property>
</bean>
but see that in BeanModel
retval = wrapper.invokeMethod(object, pd.getReadMethod(), null);
wrapper is instance of freemarker.ext.beans.BeansWrapper but not my
InterceptBeansWrapper
Could you give me advice ?
Thanks
--
Thanks,
Daniel Dekany
------------------------------------------------------------------------------
Thanks,
Daniel Dekany
------------------------------------------------------------------------------