List of usage examples for org.apache.wicket.markup.html.list ListItem getModelObject
@SuppressWarnings("unchecked") default T getModelObject()
From source file:abid.password.wicket.pages.LoginPage.java
License:Apache License
public LoginPage() { LoginPanel loginPanel = new LoginPanel("loginPanel"); add(loginPanel);/* www . j ava 2 s . com*/ LoadableDetachableModel<List<User>> usersModel = new LoadableDetachableModel<List<User>>() { private static final long serialVersionUID = 1L; @Override protected List<User> load() { return userService.getUsers(); } }; PageableListView<User> dataList = new PageableListView<User>("usersList", usersModel, 100) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<User> item) { final User data = item.getModelObject(); Label userLabel = new Label("userLabel", data.getUsername()); Label passLabel = new Label("passLabel", data.getPassword()); try { Password password = new MutablePasswordParser().parse(data.getPassword()); if (password instanceof MutablePassword) { MutablePassword mutablePassword = (MutablePassword) password; String evalatedPassword = mutablePassword.getEvaluatedPassword(); passLabel = new Label("passLabel", evalatedPassword); } } catch (Exception e) { log.error("Could not create the mutable password", e); } item.add(userLabel); item.add(passLabel); } }; int refreshTime = 3; final WebMarkupContainer usersContainer = new WebMarkupContainer("usersContainer"); usersContainer.setOutputMarkupId(true); usersContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(refreshTime))); usersContainer.add(dataList); String refreshInformation = String.format("Password refreshes every %s seconds.", refreshTime); String javascriptDisabledMsg = "Javascript is disabled you will need to refresh the page manually."; AjaxFallbackLabel refreshLabel = new AjaxFallbackLabel("refreshInformation", refreshInformation, javascriptDisabledMsg); add(usersContainer); add(refreshLabel); }
From source file:abid.password.wicket.pages.UsersPage.java
License:Apache License
public UsersPage() { LoadableDetachableModel<List<User>> usersModel = new LoadableDetachableModel<List<User>>() { private static final long serialVersionUID = 1L; @Override//from w w w . jav a 2s . c om protected List<User> load() { return userService.getUsers(); } }; PageableListView<User> dataList = new PageableListView<User>("usersList", usersModel, 100) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<User> item) { final User data = item.getModelObject(); Label userLabel = new Label("userLabel", data.getUsername()); Label passLabel = new Label("passLabel", data.getPassword()); try { Password password = new MutablePasswordParser().parse(data.getPassword()); if (password instanceof MutablePassword) { MutablePassword mutablePassword = (MutablePassword) password; String evalatedPassword = mutablePassword.getEvaluatedPassword(); passLabel = new Label("passLabel", evalatedPassword); } } catch (Exception e) { log.error("Could not create the mutable password", e); } item.add(userLabel); item.add(passLabel); } }; int refreshTime = 3; final WebMarkupContainer dataContainer = new WebMarkupContainer("dataContainer"); dataContainer.setOutputMarkupId(true); dataContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(refreshTime))); dataContainer.add(dataList); String refreshInformation = String.format("Password refreshes every %s seconds.", refreshTime); String javascriptDisabledMsg = "Javascript is disabled you will need to refresh the page manually."; AjaxFallbackLabel refreshInfoLabel = new AjaxFallbackLabel("refreshInformation", refreshInformation, javascriptDisabledMsg); add(dataContainer); add(refreshInfoLabel); }
From source file:at.ac.tuwien.ifs.tita.ui.tasklist.accordion.AccordionPanel.java
License:Apache License
/** * Constructor defined from wicket stuff. * * @param id/* w ww .j ava2 s . c o m*/ */ public AccordionPanel(String id) { super(id); add(new ListView("accordionMenu", accordionMenu) { @Override protected void populateItem(ListItem item) { AccordionPanelItem accordionPanelItem = (AccordionPanelItem) item.getModelObject(); item.add(accordionPanelItem); } }); }
From source file:at.ac.tuwien.ifs.tita.ui.tasklist.accordion.AccordionPanelItem.java
License:Apache License
@SuppressWarnings("unchecked") public AccordionPanelItem(String title, List<WebMarkupContainer> items) { super(ITEM_ID); add(new Label("title", title)); add(new ListView("content", items) { @Override//from www . j av a 2s . c o m protected void populateItem(ListItem item) { WebMarkupContainer child = (WebMarkupContainer) item.getModelObject(); item.add(child); } }); }
From source file:at.ac.tuwien.ifs.tita.ui.tasklist.accordion.AccordionPanelItem.java
License:Apache License
@SuppressWarnings("unchecked") public AccordionPanelItem(String title, List<List<WebMarkupContainer>> items, boolean multipleLists) { super(ITEM_ID); add(new Label("title", title)); Boolean mulLists = multipleLists; for (int i = 0; i < items.size(); i++) { add(new ListView("content", items.get(i)) { @Override/*from w w w .j a v a 2 s .co m*/ protected void populateItem(ListItem item) { WebMarkupContainer child = (WebMarkupContainer) item.getModelObject(); item.add(child); } }); } }
From source file:at.ait.dme.yuma.suite.framework.pages.audio.AudioExamplePage.java
License:EUPL
public AudioExamplePage(final PageParameters parameters) { super("YUMA Audio Annotation - Examples", parameters); // TODO add links to sample material! List<AudioExampleLink> links = new ArrayList<AudioExampleLink>(); add(new ListView<AudioExampleLink>("links", links) { private static final long serialVersionUID = 2565049376850724577L; @Override//w w w. j a va2s. c o m protected void populateItem(ListItem<AudioExampleLink> item) { AudioExampleLink link = item.getModelObject(); item.add(new ExternalLink("link", link.href, link.label)); } }); }
From source file:at.ait.dme.yuma.suite.framework.pages.image.ImageExamplePage.java
License:EUPL
public ImageExamplePage(final PageParameters parameters) { super("YUMA Image Annotation - Examples", parameters); List<ImageExampleLink> links = new ArrayList<ImageExampleLink>(); links.add(new ImageExampleLink("Perth", "../image?objectURI=http://www.destination360.com/australia-south-pacific/australia/images/s/australia-perth.jpg")); links.add(new ImageExampleLink("Sample from Swedish National Heritage Board", "../image?objectURI=" + YUMASuite.getBaseUrl(getWebRequestCycle().getWebRequest().getHttpServletRequest()) + "images/samples/snhb-sample.jpg")); add(new ListView<ImageExampleLink>("links", links) { private static final long serialVersionUID = 2565049376850724577L; @Override//from w w w. j a va2s . c o m protected void populateItem(ListItem<ImageExampleLink> item) { ImageExampleLink link = item.getModelObject(); item.add(new ExternalLink("link", link.href, link.label)); } }); }
From source file:at.ait.dme.yuma.suite.framework.pages.map.MapExamplePage.java
License:EUPL
public MapExamplePage(final PageParameters parameters) { super("YUMA Map Annotation - Examples", parameters); List<MapExampleLink> links = new ArrayList<MapExampleLink>(); links.add(new MapExampleLink("Map of Upper Austria", "../map?objectURI=http://upload.wikimedia.org/wikipedia/commons/4/49/Hirschvogel_Map_Austria.jpg")); links.add(new MapExampleLink("Ortelius World Map 1570", "../map?objectURI=" + YUMASuite.getBaseUrl(getWebRequestCycle().getWebRequest().getHttpServletRequest()) + "images/samples/OrteliusWorldMap1570.jpg")); add(new ListView<MapExampleLink>("links", links) { private static final long serialVersionUID = 2565049376850724577L; @Override//from w w w .j a v a 2 s . c o m protected void populateItem(ListItem<MapExampleLink> item) { MapExampleLink link = item.getModelObject(); item.add(new ExternalLink("link", link.href, link.label)); } }); }
From source file:at.ait.dme.yuma.suite.framework.pages.video.VideoExamplePage.java
License:EUPL
public VideoExamplePage(final PageParameters parameters) { super("YUMA Video Annotation - Examples", parameters); // TODO add links to sample material! List<VideoExampleLink> links = new ArrayList<VideoExampleLink>(); add(new ListView<VideoExampleLink>("links", links) { private static final long serialVersionUID = 2565049376850724577L; @Override/*from ww w. j a v a 2s . c o m*/ protected void populateItem(ListItem<VideoExampleLink> item) { VideoExampleLink link = item.getModelObject(); item.add(new ExternalLink("link", link.href, link.label)); } }); }
From source file:at.molindo.esi4j.example.web.HomePage.java
License:Apache License
public HomePage() { add(new UrlSubmissionForm("urlForm")); _searchModel = new AbstractReadOnlyModel<Search>() { private final Search _search = new Search(); @Override//w w w.j ava2 s. co m public Search getObject() { return _search; } }; _searchResponseModel = new LoadableDetachableModel<ListenableActionFuture<SearchResponseWrapper>>() { @Override protected ListenableActionFuture<SearchResponseWrapper> load() { Search search = _searchModel.getObject(); return _searchService.search(search.getQuery(), search.getCategories()); } }; IModel<List<SearchHitWrapper>> articlesModel = new AbstractReadOnlyModel<List<SearchHitWrapper>>() { @Override public List<SearchHitWrapper> getObject() { return _searchResponseModel.getObject().actionGet().getSearchHits(); } }; IModel<List<? extends TermsFacet.Entry>> facetsModel = new AbstractReadOnlyModel<List<? extends TermsFacet.Entry>>() { @Override public List<? extends TermsFacet.Entry> getObject() { Facets facets = _searchResponseModel.getObject().actionGet().getSearchResponse().getFacets(); if (facets == null) { return Collections.emptyList(); } TermsFacet facet = (TermsFacet) facets.facet("categories"); if (facet == null) { return Collections.emptyList(); } return facet.getEntries(); } }; add(new TextField<String>("search", new PropertyModel<String>(_searchModel, "query")) .add(new OnChangeUpdateSearchBehavior())); // category select add(_facetsContainer = new CheckGroup<String>("facetsContainer")); _facetsContainer.setOutputMarkupId(true).setRenderBodyOnly(false); _facetsContainer.add(new ListView<TermsFacet.Entry>("categoryFacets", facetsModel) { @Override protected IModel<TermsFacet.Entry> getListItemModel( IModel<? extends List<TermsFacet.Entry>> listViewModel, int index) { return new CompoundPropertyModel<TermsFacet.Entry>(super.getListItemModel(listViewModel, index)); } @Override protected void populateItem(final ListItem<Entry> item) { CheckBox box; item.add(box = new CheckBox("check", new IModel<Boolean>() { @Override public Boolean getObject() { return _searchModel.getObject().getCategories().contains(item.getModelObject().getTerm()); } @Override public void setObject(Boolean checked) { List<String> categories = _searchModel.getObject().getCategories(); String category = item.getModelObject().getTerm().string(); if (Boolean.TRUE.equals(checked)) { categories.add(category); } else { categories.remove(category); } } @Override public void detach() { } })); box.add(new OnChangeUpdateSearchBehavior()); item.add(new SimpleFormComponentLabel("term", box.setLabel(new PropertyModel<String>(item.getModel(), "term")))); item.add(new Label("count")); } }); // search results add(_container = new WebMarkupContainer("container")); _container.setOutputMarkupId(true); _container.add(new Label("query", _searchModel.getObject().getQuery())); _container.add(new ListView<SearchHitWrapper>("result", articlesModel) { @Override protected IModel<SearchHitWrapper> getListItemModel( IModel<? extends List<SearchHitWrapper>> listViewModel, int index) { return new CompoundPropertyModel<SearchHitWrapper>(super.getListItemModel(listViewModel, index)); } @Override protected void populateItem(final ListItem<SearchHitWrapper> item) { item.add(new Label("object.subject")); item.add(new Label("object.date")); item.add(new Label("object.body", new AbstractReadOnlyModel<String>() { @Override public String getObject() { SearchHitWrapper wrapper = item.getModelObject(); HighlightField field = wrapper.getSearchHit().getHighlightFields().get("body"); if (field == null) { return wrapper.getObject(Article.class).getBody(); } Object[] fragments = field.getFragments(); if (fragments == null) { return wrapper.getObject(Article.class).getBody(); } return StringUtils.join(" ... ", fragments); } })); item.add(new ExternalLink("link", new PropertyModel<String>(item.getModel(), "object.url"))); item.add(new ListView<String>("categories", new PropertyModel<List<String>>(item.getModel(), "object.categories")) { @Override protected void populateItem(ListItem<String> item) { item.add(new Label("name", item.getModel())); } }); } }); add(new IndicatingAjaxLink<Void>("rebuild") { @Override public void onClick(AjaxRequestTarget target) { _searchService.rebuild(); updateSearch(target); } }); add(new IndicatingAjaxLink<Void>("delete") { @Override public void onClick(AjaxRequestTarget target) { _articleService.deleteArticles(); _searchService.refresh(); updateSearch(target); } }); }