1
votes

this might be a strange question but i couldn't find any hints, ideas, howto's, whatever on this topic. Im searching for ideas or approaches to control my frontend navigation/menu in a spring based webapp.

Im using the latest Spring MVC framework with Sitemesh and JSP.

This is how i am implementing it at the moment:

The user clicks on a element in the frontend navigation ==> Request is sent and handled by my spring controller ==> now im setting a request attribute ==> next checking in my JSP if there is something to highlight in the navigation/menu.

I can see many disadvantages of this approach as i need to handle this always manually in my controller actions and jsps plus to this it feels somehow really overloaded as this is the way i have seen in good old struts webapps 10 years ago...

Does anybody have any ideas how to implement a clean and straight forward navigation strategy?

1

1 Answers

1
votes

This is what I did in my SiteMesh decorator:

<c:set var="path" value="${requestScope['javax.servlet.forward.request_uri']}"/>

Later, in the menu...

<li class="${fn:startsWith(path, '/somePath')?' active':''}">
  <a href="<c:url value='/somePath/whatever'/>">Some Path</a>
</li>