Package com.vaadin.spring.navigator
Class SpringViewProvider
java.lang.Object
com.vaadin.spring.navigator.SpringViewProvider
- All Implemented Interfaces:
com.vaadin.navigator.ViewProvider,Serializable
A Vaadin
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.
- Author:
- Petter Holmström (petter@vaadin.com), Henri Sara (hesara@vaadin.com)
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classInternal class used to communicate info on available views within the view provider. -
Constructor Summary
ConstructorsConstructorDescriptionSpringViewProvider(org.springframework.context.ApplicationContext applicationContext, org.springframework.beans.factory.support.BeanDefinitionRegistry beanDefinitionRegistry) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.vaadin.navigator.ViewReturns an instance of the access denied view from the application context based onsetAccessDeniedViewClass(Class).Class<? extends com.vaadin.navigator.View>Returns the class of the access denied view.protected List<SpringViewProvider.ViewInfo>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>Return a collection with all the registered Spring views for the current UI regardless of access restrictions.protected org.springframework.beans.factory.support.BeanDefinitionRegistrycom.vaadin.navigator.Viewprotected com.vaadin.navigator.ViewFetches a view from the application context.protected com.vaadin.navigator.ViewgetViewName(String viewAndParameters) protected StringgetViewName(String viewAndParameters, List<SpringViewProvider.ViewInfo> views) protected StringgetViewNameFromAnnotation(Class<?> beanClass, SpringView annotation) Return a collection with all the registered Spring views for the current UI which the current user is allowed to access.Get the mapping from view names to the collections of corresponding bean names.protected org.springframework.context.ApplicationContextprotected booleanprotected booleanisAccessGrantedToViewInstance(SpringViewProvider.ViewInfo viewInfo, com.vaadin.navigator.View view) protected booleanvoidsetAccessDeniedViewClass(Class<? extends com.vaadin.navigator.View> accessDeniedViewClass) Sets the class of the access denied view.
-
Constructor Details
-
SpringViewProvider
@Autowired public SpringViewProvider(org.springframework.context.ApplicationContext applicationContext, org.springframework.beans.factory.support.BeanDefinitionRegistry beanDefinitionRegistry)
-
-
Method Details
-
getAccessDeniedViewClass
Returns the class of the access denied view. If set, a bean of this type will be fetched from the application context and showed to the user when aViewAccessControlor aViewInstanceAccessControldenies access to a view.- Returns:
- the access denied view class, or
nullif not set.
-
setAccessDeniedViewClass
public void setAccessDeniedViewClass(Class<? extends com.vaadin.navigator.View> accessDeniedViewClass) Sets the class of the access denied view. If set, a bean of this type will be fetched from the application context and showed to the user when aViewAccessControlor aViewInstanceAccessControldenies access to a view.- Parameters:
accessDeniedViewClass- the access denied view class, may benull.
-
getViewNameFromAnnotation
-
getAllViewsForCurrentUI
Return a collection with all the registered Spring views for the current UI regardless of access restrictions.- Returns:
- list of ViewInfo, not null
-
getAllowedViewsForCurrentUI
Return a collection with all the registered Spring views for the current UI which the current user is allowed to access. Note that only view type/bean level access is checked (ViewAccessControl), and view instance specific checks (ViewInstanceAccessControl) are not applied.- Returns:
- list of ViewInfo, not null
-
getAllowedViewsForCurrentUI
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. Note that only view type/bean level access is checked (ViewAccessControl), and view instance specific checks (ViewInstanceAccessControl) are not applied.- Parameters:
viewName- view name in the form returned bygetViewName(String)(no parameters)- Returns:
- list of ViewInfo, not null
-
getViewNamesForCurrentUI
Return a collection with all the registered Spring views for the current UI which the current user is allowed to access. Note that only view type/bean level access is checked (ViewAccessControl), and view instance specific checks (ViewInstanceAccessControl) are not applied.- Returns:
- collection of view names, not null
-
getViewName
- Specified by:
getViewNamein interfacecom.vaadin.navigator.ViewProvider
-
getViewName
-
getView
- Specified by:
getViewin interfacecom.vaadin.navigator.ViewProvider
-
getBeanDefinitionRegistry
protected org.springframework.beans.factory.support.BeanDefinitionRegistry getBeanDefinitionRegistry() -
getAccessDeniedView
protected com.vaadin.navigator.View getAccessDeniedView()Returns an instance of the access denied view from the application context based onsetAccessDeniedViewClass(Class).- Returns:
- access denied view instance from application context or null if no access denied view class is set
-
getWebApplicationContext
protected org.springframework.context.ApplicationContext getWebApplicationContext() -
getViewNameToBeanNamesMap
Get the mapping from view names to the collections of corresponding bean names. This method is primarily for internal use, and users should typically overridegetAllViewsForCurrentUI()orgetAllowedViewsForCurrentUI()instead of using this method.- Returns:
- internal mapping from view names to correspoding bean names
-