SiteMap

From Lift

Jump to: navigation, search

Overview

For a page to be seen in a lift app, it must be added to the project's SiteMap. SiteMap allows you to define permissions for pages and can also be used to create breadcrumb navigation and navigation menus. All new projects come with a default SiteMap in Boot that can optionally be removed.

Examples

Simple sitemap:

 val entries = Menu(Loc("Home", "/", "Home")) :: 
               Menu(Loc("Foo", "/badger", "Foo")) ::
               Menu(Loc("Directory Foo", "/something/foo", "Directory Foo")) :: Nil 
 LiftRules.setSiteMap(SiteMap(entries:_*))

Breaking this down, the first line defines the root page, which will default to the index.html file found in src/main/webapp within your application. This is a default when you start a 'basic' lift application.

Menu(Loc("Home", "/", "Home")) :: 

The second line defines access to the badger.html file. The URI to access this page would be (on localhost) http://127.0.0.1:8080/badger (note that the .html extension is uneccessary). It is also possible to group pages in sub-directories within the webapp directory of your project if you so wish, in which case your site map entry would look like the third line:

Menu(Loc("Directory Foo", "/something/foo", "Directory Foo")) :: Nil

Its important to note that the SiteMap controls access to the pages it lists. Anything not defined in the SiteMap will give a 404 error to the client. Also note that if you had a rewrite rule in which you rewrote the http://127.0.0.1:8080/badger page to point to http://127.0.0.1:8080/myfoopage internally (line 2 in the above site map), then you would not need to have a new entry for that page.

Its also important to note that with sitemap...

/some/url

vs

/some/url/

ARE HANDLED DIFFERENTLY - as such, you will need to allow for both URL's if thats what you want. The latter URL effectivly maps out to become:

/some/url/index

Lift Render Pipeline

Some usefull notes about the way lift handles its request handling can be found here

Personal tools