|
From: Darren D. <da...@da...> - 2004-05-07 08:26:12
|
A project of mine uses a servlet Filter to pre-process many http requests= , as a result of which objects are occasionally added to the user's HttpSession or as request attributes. I need these objects to be available in some views, regardless of which controller eventually handled the request. That's OK for JSP/JSTL and even Spring's XSLT and Document based views that have access to them, but awkward for Velocity/FreeMarker. It's not difficult to extend these view= s to cope, but I wondered if it would be better as an addition to the framework classes. Two new bean properties would exist on VelocityView (also applies to FreeMarkerView so possibly in a new AbstractTemplateView below AbstractUrlBasedView)... private boolean exposeRequestAttributes =3D false; private boolean exposeSessionAttributes =3D false; // corresponding public mutators omitted The rendering methods can then use these properties to decide whether to put request/session objects into the velocityContext or FreeMarker model. There's obviously a good argument that says the controller is solely responsible for deciding what ends up in the model, but the following issues arise in that case: i. If a view currently takes advantage of having access to the request/session, then switching view technologies to a template view is impossible without amending controller code or specifying a HandlerInterceptor to expose the same objects. ii. If a HandlerInterceptor is not used (potentially awkward to configure) then all controllers would potentially have to be modified to cater for the requirement. A common app-specific superclass would be impossible if the behaviour was required from both FormControllers and SimpleControllers Thoughts? --=20 Darren Davison Public Key: http://www.davison.uk.net/key.jsp |