PDA

View Full Version : all pages in my web application need certain data



jpwillms
Feb 21st, 2005, 01:27 AM
Hi there,

I have a web application, that has certain data that every page needs. ie. Username, a dynmamically created menu, etc. I was wondering if AOP is the solution to this, so I don't have to have code put in every single controller in my application.

Any help, advice, resources you can direct me to would be greatly appretiated.

..jordan

cmgharris
Feb 21st, 2005, 03:17 AM
I do this in a HandlerInterceptor, in the postHandle() method.

Something like:

public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView mnv) {
if (!(mnv.getView() instanceof RedirectView)) {
mnv.getModel().put("name", object):
}
}

HTH

Costin Leau
Feb 21st, 2005, 03:53 AM
AOP can do this but you can use also a customized solution like SiteMesh (or Jakarta Tiles). In our application we have dynamical pages which contain a common skeleton but have to be 'decorated' differently based on some factors (like the user properties).
I don't know your requirements but give it try - it may save you some trouble .