Results 1 to 4 of 4

Thread: How to implement a controller for an included page?

  1. #1
    Join Date
    Dec 2009
    Posts
    4

    Question How to implement a controller for an included page?

    Hi All,

    In the Spring Roo project, there is an included page "/WEB-INF/views/menu.jspx" which defined in layouts.xml:

    <definition name="default" template="/WEB-INF/layouts/default.jspx">
    <put-attribute name="menu" value="/WEB-INF/views/menu.jspx" />
    </definition>

    It is an static HTML, but now I would like to do some programming work before this page shown.

    I know a controller define with "@Controller" and "@RequestMapping("/xx")" for page URL.

    But, how can I implement a controller for an included page without explicit URL?

    thanks advance!

  2. #2
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    This is a quite unusual question. Can you please elaborate a little more on what you are actually trying to do? Most probably we can suggest a different solution than having a controller for your menu.
    Stefan Schmidt
    Software Engineer, Spring Roo
    SpringSource - a division of VMware
    twitter @schmidtstefan

  3. #3
    Join Date
    Dec 2009
    Posts
    4

    Default

    Quote Originally Posted by Stefan Schmidt View Post
    This is a quite unusual question. Can you please elaborate a little more on what you are actually trying to do? Most probably we can suggest a different solution than having a controller for your menu.
    Well.

    My project is a content management system. In the published web site, almost all page including a common menu, which contain channels links.

    These channels are dynamically load from database and can be defined dynamically.

    So, I designed an embeded page call "menu.jspx" shared for all pages.
    And if a controller or anything like that just for it, we can clearly separate the logic from other.

    Is there any advice?

  4. #4
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    Personally I would consider using Spring Security for this purpose. You could then display menu items based on the user or role who is logged in. Spring Security 3 offers convenient @PreFilter or @PostFilterin conjunction with the new expression language support which would be of use for your application. Please refer to the Spring security docs for details. I have also written a blog post a while back on a related subject.

    HTH
    Stefan Schmidt
    Software Engineer, Spring Roo
    SpringSource - a division of VMware
    twitter @schmidtstefan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •