/** * Constructor for SharedAlbums. * * @param parameters The parameters necessaries for load the page. */ public SharedAlbums(final PageParameters parameters) { super(parameters); if (parameters.getNamedKeys().contains("user")) { final String email = parameters.get("user").toString(); User user = new User(); user.setEmail(email); if (userService.getUser(user) == null) { throw new RestartResponseException(ErrorPage404.class); } this.user = user; add(new AjaxDataView("dataContainer", "navigator", createShareDataView())); } else { throw new RestartResponseException(ErrorPage404.class); } }
/** * Method createShareDataView that shown a list of shared {@link Album}s. * * @return DataView<{@link Album}> the data view with the list of {@link Album}. */ private DataView<Album> createShareDataView() { List<Album> list = albumService.getAlbumsSharedWith(((MySession) Session.get()).getuId(), user.getEmail()); DataView<Album> dataView = new DataView<Album>("pageable", new ListDataProvider<Album>(list)) { public void populateItem(final Item<Album> item) { final Album album = item.getModelObject(); PageParameters pars = new PageParameters(); pars.add("user", user.getEmail()); pars.add("album", album.getName()); BookmarkablePageLink<Void> bp = new BookmarkablePageLink<Void>("link", SharedFiles.class, pars); bp.add(new Label("name", album.getName())); item.add(bp); } }; dataView.setItemsPerPage(ITEMS_PER_PAGE); return dataView; }