View Annotations
Annotations on view classes provide information about the views to the framework. Some annotations are applicable to any type of view, some of them can be used only on entity list or detail views.
Common Annotations
@ViewController("MyOnboardingView")
@ViewDescriptor("my-onboarding-view.xml")
@Route(value = "my-onboarding", layout = MainView.class)
@DialogMode(width = "AUTO", height = "AUTO")
public class MyOnboardingView extends StandardView {
-
@ViewControllerannotation indicates that the class is a view. The value of the annotation is the view id which can be used to refer to the view from the main menu or when opening the view programmatically. -
@ViewDescriptorannotation connects the view class to the XML descriptor. The value of the annotation specifies the path to the descriptor file. If the value contains a file name only, it is assumed that the file is located in the same package as the view class. -
@com.vaadin.flow.router.Routedefines a URL path for navigation to this view. As long as the view should be opened inside the main view, thelayoutattribute specifies the main view class. -
@DialogModeannotation defines parameters of the dialog window when the view is opened as a dialog. -
@com.vaadin.flow.server.auth.AnonymousAllowedmakes the view available without authentication. By default, only the login view is available to the anonymous (not authenticated) session.See the User Registration sample project for how the @AnonymousAllowedannotation is used in a view for self-registration of users.
List View Annotations
// common annotations
@ViewController("Department.list")
@ViewDescriptor("department-list-view.xml")
@Route(value = "departments", layout = MainView.class)
@DialogMode(width = "50em", height = "37.5em")
// list view annotations
@LookupComponent("departmentsTable")
@PrimaryLookupView(Department.class)
public class DepartmentListView extends StandardListView<Department> {
-
@LookupComponentannotation specifies an id of a UI component to be used for getting a value returned from the lookup. -
@PrimaryLookupViewannotation indicates that this view is the default lookup view for the specified entity. The annotation has greater priority than the{entity_name}.lookup/{entity_name}.listname convention.
Detail View Annotations
// common annotations
@ViewController("Department.detail")
@ViewDescriptor("department-detail-view.xml")
@Route(value = "departments/:id", layout = MainView.class)
// detail view annotations
@EditedEntityContainer("departmentDc")
@PrimaryDetailView(Department.class)
public class DepartmentDetailView extends StandardDetailView<Department> {
-
@EditedEntityContainerannotation specifies a data container that contains the edited entity. -
@PrimaryDetailViewannotation indicates that this view is the default detail view for the specified entity. The annotation has greater priority than the{entity_name}.detailname convention.