List of usage examples for org.apache.wicket.extensions.markup.html.repeater.data.table DataTable addTopToolbar
public void addTopToolbar(final AbstractToolbar toolbar)
From source file:org.wintersleep.usermgmt.wicket.UserListPage.java
License:Apache License
public UserListPage() { super();// ww w . ja va 2 s. c o m List<IColumn<User, String>> columns = new ArrayList<>(); columns.add(new FilteredAbstractColumn<User, String>(new Model<>("Actions")) { public void populateItem(Item<ICellPopulator<User>> cellItem, String componentId, final IModel<User> model) { cellItem.add(new ActionsPanel(componentId, new PageSourceLink<>("showLink", UserEditPage.class, model), new IPageLink() { public Page getPage() { return new UserEditPage(UserListPage.this, (HibernateObjectModel<Long, User>) model); } public Class<UserEditPage> getPageIdentity() { return UserEditPage.class; } }, new IPageLink() { public Page getPage() { User user = model.getObject(); return new DeletePage<>(UserListPage.this, model, "User: " + user.getFullName()); } public Class<DeletePage> getPageIdentity() { return DeletePage.class; } })); } public Component getFilter(String componentId, FilterForm<?> form) { return new GoAndClearAndNewFilter(componentId, form) { public Page createNewPage() { return new UserEditPage(UserListPage.this, new HibernateObjectModel<Long, User>(new User(WicketHibernateUtil.EMPTY_STRING))); } }; } }); columns.add(new TextFilteredPropertyColumn<User, User, String>(new Model<>("Login"), "login", "login")); columns.add( new TextFilteredPropertyColumn<User, User, String>(new Model<>("Name"), "fullName", "fullName")); /* // custom column to enable countries be be in the list and labeled correctly new MyChoiceFilteredPropertyColumn(new Model("Birth country"), "country.name", "country.name", "country", "name", countries), new MyChoiceFilteredPropertyColumn(new Model("Birth city"), "birthCity.name", "birthCity.name", "birthCity", "name", cities), new PropertyColumn(new Model("Final game"), "finalGame", "finalGame") */ UserFilter filter = new UserFilter(); final FilterForm<UserFilterState> filterForm = new FilterForm<>("form", filter); CriteriaSorter sorter = new CriteriaSorter(); HibernateProvider<Long, User> provider = new HibernateProvider<>(User.class, filter, sorter); DataTable<User, String> table = new DataTable<User, String>("table", columns, provider, 25) { protected Item<User> newRowItem(String id, int index, IModel<User> model) { return new OddEvenItem<>(id, index, model); } }; table.addTopToolbar(new NavigationToolbar(table)); table.addTopToolbar(new HeadersToolbar<>(table, sorter)); table.addTopToolbar(new FilterToolbar(table, filterForm, filter)); add(filterForm.add(table)); }
From source file:org.wintersleep.usermgmt.wicket.UserProfileListPage.java
License:Apache License
public UserProfileListPage() { super();//from ww w .j a v a 2 s. c om UserProfileFilter filter = new UserProfileFilter(); final FilterForm<UserProfileFilterState> form = new FilterForm<>("form", filter); List<IColumn<UserProfile, String>> columns = new ArrayList<>(); columns.add(new FilteredAbstractColumn<UserProfile, String>(new Model<>("Actions")) { public void populateItem(Item<ICellPopulator<UserProfile>> cellItem, String componentId, final IModel<UserProfile> model) { cellItem.add(new ActionsPanel(componentId, new PageSourceLink<>("showLink", UserProfileEditPage.class, model), new IPageLink() { public Page getPage() { return new UserProfileEditPage(UserProfileListPage.this, model); } public Class<UserProfileEditPage> getPageIdentity() { return UserProfileEditPage.class; } }, new IPageLink() { public Page getPage() { UserProfile userProfile = model.getObject(); return new DeletePage<>(UserProfileListPage.this, model, "User Profile: " + userProfile.getName()); } public Class<DeletePage> getPageIdentity() { return DeletePage.class; } })); } public Component getFilter(String componentId, FilterForm form) { return new GoAndClearAndNewFilter(componentId, form) { public Page createNewPage() { return new UserProfileEditPage(UserProfileListPage.this, new HibernateObjectModel<Long, UserProfile>( new UserProfile(WicketHibernateUtil.EMPTY_STRING))); } }; } }); columns.add(new TextFilteredPropertyColumn<UserProfile, UserProfile, String>(new Model<>("Name"), "name", "name")); //new MyChoiceFilteredPropertyColumn(new Model("Role"), "role.name", "role.name", "role", "name", roles), /* new MyChoiceFilteredPropertyColumn(new Model("Birth city"), "birthCity.name", "birthCity.name", "birthCity", "name", cities), new PropertyColumn(new Model("Final game"), "finalGame", "finalGame") */ CriteriaSorter sorter = new CriteriaSorter(); HibernateProvider<Long, UserProfile> provider = new HibernateProvider<>(UserProfile.class, filter, sorter); DataTable<UserProfile, String> table = new DataTable<UserProfile, String>("table", columns, provider, 25) { protected Item<UserProfile> newRowItem(String id, int index, IModel<UserProfile> model) { return new OddEvenItem<>(id, index, model); } }; table.addTopToolbar(new NavigationToolbar(table)); table.addTopToolbar(new HeadersToolbar<>(table, sorter)); table.addTopToolbar(new FilterToolbar(table, form, filter)); add(form.add(table)); }
From source file:sk.lazyman.gizmo.component.data.TablePanel.java
License:Apache License
private void initLayout(List<IColumn<T, String>> columns, ISortableDataProvider provider, int rowsPerPage) { DataTable<T, String> table = new DataTable<>(ID_TABLE, columns, provider, rowsPerPage); table.setOutputMarkupId(true);//from w w w. j av a2 s .c o m TableHeadersToolbar headers = new TableHeadersToolbar(table, provider); headers.setOutputMarkupId(true); table.addTopToolbar(headers); CountToolbar count = new CountToolbar(table); addVisibleBehaviour(count, showCount); table.addBottomToolbar(count); add(table); NavigatorPanel nb2 = new NavigatorPanel(ID_PAGING, table, true); addVisibleBehaviour(nb2, showPaging); add(nb2); setItemsPerPage(rowsPerPage); }