O'Reilly logo

Lift Application Development Cookbook by Gilberto T. Garcia Jr.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dynamic menu rendering

Menus are an important part of an application. They show a hierarchical structure and how the application is organized. Users will use them to navigate through the application.

Lift does offer a good built-in snippet for creating menus, as I briefly said before. In this recipe, I'll show you how to use this snippet to create complex menu structures, and how to render them with fine-grained control.

Getting ready

Create a new project and add the following code in the Boot class to create the SiteMap:

Val isAdmin_? = If(() => { S.param("admin").flatMap(asBoolean).openOr(false) }, () => RedirectWithState("/", MessageState( "Authorized personnel only" -> NoticeType.Warning)) ) val entries = List( Menu.i("Home") / "index" >> LocGroup("content"), ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required