package org.apache.wicket.examples.authorization;
import org.apache.wicket.Session;
import org.apache.wicket.examples.authorization.pages.AdminAnnotationsBookmarkablePage;
import org.apache.wicket.examples.authorization.pages.AdminAnnotationsInternalPage;
import org.apache.wicket.examples.authorization.pages.AdminBookmarkablePage;
import org.apache.wicket.examples.authorization.pages.AdminInternalPage;
import org.apache.wicket.examples.authorization.pages.AnnotationsPanelsPage;
import org.apache.wicket.examples.authorization.pages.PanelsPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
@author
public class Index extends BasePage
{
public Index()
{
add(new Label("currentUser", new PropertyModel<>(this, "session.user")));
add(new ListView<User>("users", RolesApplication.USERS)
{
@Override
protected void populateItem(ListItem<User> item)
{
final User user = item.getModelObject();
item.add(new Link<Void>("selectUserLink")
{
@Override
public void onClick()
{
RolesSession session = (RolesSession)Session.get();
session.setUser(user);
}
}.add(new Label("userId", new Model<>(user))));
}
});
add(new BookmarkablePageLink<>("adminBookmarkableLink", AdminBookmarkablePage.class));
add(new Link<Void>("adminInternalLink")
{
@Override
public void onClick()
{
setResponsePage(new AdminInternalPage("foo"));
}
});
add(new BookmarkablePageLink<>("panelsPageLink", PanelsPage.class));
add(new BookmarkablePageLink<Void>("adminAnnotBookmarkableLink",
AdminAnnotationsBookmarkablePage.class));
add(new Link<Void>("adminAnnotInternalLink") {
public void onClick() {
setResponsePage(new AdminAnnotationsInternalPage("bar"));
}
});
add(new BookmarkablePageLink<>("panelsAnnotPageLink", AnnotationsPanelsPage.class));
}
}