dynamic menu selection using site mesh

one of the common features in the web applications is to highlight the menu item that corresponds to the current page so that users know where they are in the application.

here is how:

In decoratee, define the page’s menu information in meta data:

<head>
<meta name=”menu” content=”home” />
<meta name=”refreshInterval” content=”1″ />
</head>

In decorator, make sure to include the decoratee’s header and retrieve the value:

<html>

<head><decorator:head /></head>

<!–  Script to select the active page’s button –>
<script>
//get the selected page’s menu
var selected = ‘<decorator:getProperty property=’meta.menu’ />’;
select(selected);

function select(buttonId) {
var myButton = document.getElementById(buttonId);
if(myButton != null) {
//change the button’s class to highlighted as defined in css

myButton.class=’highlightedMenu’;

}
}
</script>

<body>

<decorator:body />

</body>

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.