--En-/Disable navigation programmatically
1 post
• Page 1 of 1
--En-/Disable navigation programmatically
This article is outdated - please use our new system at
https://doc.sibvisions.com
The standard application frame supports navigation between screens with Back/Forward buttons of the web browser. This feature is disabled by default. If you want to use the navigation with Back/Forward, simply add:
<servlet>
<servlet-name>VaadinUI</servlet-name>
<servlet-class>com.sibvisions.rad.ui.vaadin.server.VaadinServlet</servlet-class>
...
<init-param>
<param-name>Application.navigation</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-name>VaadinUI</servlet-name>
<servlet-class>com.sibvisions.rad.ui.vaadin.server.VaadinServlet</servlet-class>
...
<init-param>
<param-name>Application.navigation</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
to the web.xml.
Above setting is for the whole application and for all users. If you want finer control, it's possible to en-/disable the navigation in your application code, programmatically. A common use-case is that you en-/disable the navigation per user. To do this, create your own application (see CustomApplication class).
Use following code snippet:
@Override
public void initUserRoles(String[] pRoles)
{
super.initUserRoles(pRoles);
((WebMenu)getMenu()).setNavigationEnabled(hasRole("admin"));
}
public void initUserRoles(String[] pRoles)
{
super.initUserRoles(pRoles);
((WebMenu)getMenu()).setNavigationEnabled(hasRole("admin"));
}
to en-/disable navigation.
It's important that you en-/disable the navigation in initUserRoles, because it's not possible to en-/disable the navigation after the menu was loaded.
-
Development@SIB - Posts: 325
- Joined: Mon Sep 28, 2009 1:54 pm
1 post
• Page 1 of 1