public class SpringViewProvider extends Object implements com.vaadin.navigator.ViewProvider
ViewProvider that fetches the views from the Spring
application context. The views must implement the View interface and
be annotated with the SpringView annotation.
Use like this:
@SpringUI
public class MyUI extends UI {
@Autowired
SpringViewProvider viewProvider;
protected void init(VaadinRequest vaadinRequest) {
Navigator navigator = new Navigator(this, this);
navigator.addProvider(viewProvider);
setNavigator(navigator);
// ...
}
}
View-based security can be provided by creating a Spring bean that implements
the interface ViewAccessControl (for view
bean name and annotation based security) or
ViewInstanceAccessControl (if view instance
specific contextual data is needed). It is also possible to set an 'Access
Denied' view by using setAccessDeniedViewClass(Class).
To specify a view to show when no matching view is found, use
SpringNavigator.setErrorView(Class). Unlike version 1.0, version 1.1
does not use the access denied view always when no matching view is found.
SpringView,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
protected static class |
SpringViewProvider.ViewInfo
Internal class used to communicate info on available views within the
view provider.
|
| Constructor and Description |
|---|
SpringViewProvider(org.springframework.context.ApplicationContext applicationContext,
org.springframework.beans.factory.support.BeanDefinitionRegistry beanDefinitionRegistry) |
| Modifier and Type | Method and Description |
|---|---|
protected com.vaadin.navigator.View |
getAccessDeniedView()
Returns an instance of the access denied view from the application
context based on
setAccessDeniedViewClass(Class). |
Class<? extends com.vaadin.navigator.View> |
getAccessDeniedViewClass()
Returns the class of the access denied view.
|
protected List<SpringViewProvider.ViewInfo> |
getAllowedViewsForCurrentUI()
Return a collection with all the registered Spring views for the current
UI which the current user is allowed to access.
|
protected List<SpringViewProvider.ViewInfo> |
getAllowedViewsForCurrentUI(String viewName)
Return a collection with all the registered Spring views with the given
view name for the current UI and which the current user is allowed to
access.
|
protected List<SpringViewProvider.ViewInfo> |
getAllViewsForCurrentUI()
Return a collection with all the registered Spring views for the current
UI regardless of access restrictions.
|
protected org.springframework.beans.factory.support.BeanDefinitionRegistry |
getBeanDefinitionRegistry() |
com.vaadin.navigator.View |
getView(String viewName) |
protected com.vaadin.navigator.View |
getViewFromApplicationContext(SpringViewProvider.ViewInfo viewInfo)
Fetches a view from the application context.
|
protected com.vaadin.navigator.View |
getViewFromApplicationContextAndCheckAccess(SpringViewProvider.ViewInfo viewInfo) |
String |
getViewName(String viewAndParameters) |
protected String |
getViewName(String viewAndParameters,
List<SpringViewProvider.ViewInfo> views) |
protected String |
getViewNameFromAnnotation(Class<?> beanClass,
SpringView annotation) |
Collection<String> |
getViewNamesForCurrentUI()
Return a collection with all the registered Spring views for the current
UI which the current user is allowed to access.
|
protected Map<String,Set<String>> |
getViewNameToBeanNamesMap()
Get the mapping from view names to the collections of corresponding bean
names.
|
protected org.springframework.context.ApplicationContext |
getWebApplicationContext() |
protected boolean |
isAccessGranted(SpringViewProvider.ViewInfo view) |
protected boolean |
isAccessGrantedToViewInstance(SpringViewProvider.ViewInfo viewInfo,
com.vaadin.navigator.View view) |
protected boolean |
isViewValidForCurrentUI(SpringViewProvider.ViewInfo viewInfo) |
void |
setAccessDeniedViewClass(Class<? extends com.vaadin.navigator.View> accessDeniedViewClass)
Sets the class of the access denied view.
|
@Autowired
public SpringViewProvider(org.springframework.context.ApplicationContext applicationContext,
org.springframework.beans.factory.support.BeanDefinitionRegistry beanDefinitionRegistry)
public Class<? extends com.vaadin.navigator.View> getAccessDeniedViewClass()
ViewAccessControl or a
ViewInstanceAccessControl denies access
to a view.null if not set.public void setAccessDeniedViewClass(Class<? extends com.vaadin.navigator.View> accessDeniedViewClass)
ViewAccessControl or a
ViewInstanceAccessControl denies access
to a view.accessDeniedViewClass - the access denied view class, may be null.protected String getViewNameFromAnnotation(Class<?> beanClass, SpringView annotation)
protected List<SpringViewProvider.ViewInfo> getAllViewsForCurrentUI()
protected List<SpringViewProvider.ViewInfo> getAllowedViewsForCurrentUI()
ViewAccessControl), and view
instance specific checks (ViewInstanceAccessControl) are not
applied.protected List<SpringViewProvider.ViewInfo> getAllowedViewsForCurrentUI(String viewName)
ViewAccessControl), and view instance specific checks
(ViewInstanceAccessControl) are not applied.viewName - view name in the form returned by getViewName(String)
(no parameters)public Collection<String> getViewNamesForCurrentUI()
ViewAccessControl), and view
instance specific checks (ViewInstanceAccessControl) are not
applied.public String getViewName(String viewAndParameters)
getViewName in interface com.vaadin.navigator.ViewProviderprotected String getViewName(String viewAndParameters, List<SpringViewProvider.ViewInfo> views)
protected boolean isViewValidForCurrentUI(SpringViewProvider.ViewInfo viewInfo)
public com.vaadin.navigator.View getView(String viewName)
getView in interface com.vaadin.navigator.ViewProviderprotected com.vaadin.navigator.View getViewFromApplicationContext(SpringViewProvider.ViewInfo viewInfo)
viewInfo - view metadataorg.springframework.beans.BeansException - if no suitable bean is found or view scope initialization
failedprotected org.springframework.beans.factory.support.BeanDefinitionRegistry getBeanDefinitionRegistry()
protected com.vaadin.navigator.View getViewFromApplicationContextAndCheckAccess(SpringViewProvider.ViewInfo viewInfo)
protected com.vaadin.navigator.View getAccessDeniedView()
setAccessDeniedViewClass(Class).protected boolean isAccessGranted(SpringViewProvider.ViewInfo view)
protected boolean isAccessGrantedToViewInstance(SpringViewProvider.ViewInfo viewInfo, com.vaadin.navigator.View view)
protected org.springframework.context.ApplicationContext getWebApplicationContext()
protected Map<String,Set<String>> getViewNameToBeanNamesMap()
getAllViewsForCurrentUI() or
getAllowedViewsForCurrentUI() instead of using this method.Copyright © 2019 Vaadin Ltd. All Rights Reserved.