I have a view called SpaceView which represents the data of one space. I have multiple spaces with different data. Dependend on the data a different number of tabs exists/are opened therefore I need for each Space an own instance of the SpaceView, it is not enough that the data of the space is changed dependend on the selected space.
Space 1: Link to SpaceView.class with uid 123, which has 3 tabs
Space 2: Link to SpaceView.class with uid 567, which has only one tab
These navigation links are created dynamically.
How can I realize this? Spaceview.class:
@Route(value = “application/module/space/:spaceId”, layout = ApplicationLayout.class)
@PermitAll
public class SpaceView extends VerticalLayout implements BeforeEnterObserver {
private ApplicationService applicationService;
private SharedFolderService sharedFolderService;
private SpaceService spaceService;
private SpaceController spaceController;
private SpaceSingleView spaceSingleView;
public static String url = "application/module/space/";
public SpaceView(ApplicationService applicationService, SharedFolderService sharedFolderService, SpaceService spaceService) {
this.applicationService = applicationService;
this.sharedFolderService = sharedFolderService;
this.spaceService = spaceService;
this.spaceController = new SpaceController(applicationService.getOrganization());
this.setSizeFull();
this.addClassName("no-margin");
this.spaceSingleView = new SpaceSingleView(applicationService, sharedFolderService, spaceService, spaceController);
this.add(spaceSingleView);
this.expand(spaceSingleView);
}
/*
@Override
public void setParameter(BeforeEvent beforeEvent, String parameter) {
System.out.println("SpaceView: setParameter: "+parameter);
}*/
@Override
public void beforeEnter(BeforeEnterEvent beforeEnterEvent) {
String spaceId = beforeEnterEvent.getRouteParameters().get("spaceId").get();
System.out.println("SpaceView: beforeEnter: "+spaceId);
// Try to get the space based on the uid and put it into the hashmaps of tabs
try {
Space space = spaceService.openSpace(spaceId);
if(space == null) {
DefaultNotification.show(AppIcon.error(), "Space nicht gefunden");
getUI().ifPresent(ui -> ui.navigate(SpaceOverview.class));
} else {
this.spaceController.setSpace(space, applicationService.getOrganizationUser());
this.spaceSingleView.updateComponent();
}
} catch (UserHasNoAccessRightsException e) {
DefaultNotification.notEnoughRights();
}
}
}
Thanks Florian?