Scoped Model Driven Interceptor

In my struts 2 project, I have an action that implements the ScopedModelDriven interface.

I have configuration that references the ScopedModelDrivenInterceptor with a session scope…

<interceptor name="scoped-model-driven" class="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor"> 
  <param name="scope">session</param> 

My action references this interceptor and specifies the key used when the object was previously put in the session.

<interceptor-ref name="scoped-model-driven"> 
  <param name="name">session-key</param> 

This all works fine, except in my freemarker templates I now need to reference model.myproperty, rather than just property.

I could live with that, but unfortunately

<#if myproperty?has_content> ...

no longer returns any results and worse

<#if model.myproperty?has_content> ...

blows up completely!

javax.servlet.ServletException: ?size is unsupported for: freemarker.ext.beans.SimpleMethodModel

I’ve tried a few variations of reference to no avail.

Very disappointing.

The reason I’m writing this up is that the scoped model driven thing looked almost exactly how I wanted to go with these actions, so I want to remember where I got to, but getting it working is more important.

Back to ModelDriven, SessionAware and Preparable…

comments powered by Disqus