Announcement Announcement Module
Collapse
No announcement yet.
all pages in my web application need certain data Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • all pages in my web application need certain data

    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

  • #2
    I do this in a HandlerInterceptor, in the postHandle() method.

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

    Comment


    • #3
      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 .

      Comment

      Working...
      X