List of usage examples for org.apache.wicket.markup.html.list ListView setList
public ListView<T> setList(List<T> list)
From source file:net.java.ao.blog.pages.ViewPost.java
License:Apache License
public ViewPost(PageParameters params) { final Post post = ((BlogApplication) getApplication()).getEntityManager().get(Post.class, Integer.parseInt((String) params.get("item"))); pageTitle = post.getBlog().getName() + ": " + post.getTitle(); postedFormatted = DateFormat.getDateTimeInstance().format(post.getPublished().getTime()); Link indexLink = new BookmarkablePageLink("indexLink", Index.class); add(indexLink);//from w w w . j a v a 2s .c om indexLink.add(new Label("blogTitle", new PropertyModel(post.getBlog(), "name"))); add(new Label("pageTitle", new PropertyModel(this, "pageTitle"))); add(new Label("pageHeader", new PropertyModel(post, "title"))); add(new PageLink("editPostLink", new EditPost(this, post.getBlog(), post))); add(new Label("posted", new PropertyModel(this, "postedFormatted"))); add(new MultiLineLabel("text", new PropertyModel(post, "text"))); final ListView comments = new ListView("comments", Arrays.asList(post.getComments())) { @Override protected void populateItem(ListItem item) { Comment comment = (Comment) item.getModelObject(); item.add(new Label("commentBy", new PropertyModel(comment, "name"))); item.add(new MultiLineLabel("comment", new PropertyModel(comment, "comment"))); } }; add(comments); final CommentBean commentBean = new CommentBean(); Form commentForm = new Form("commentForm") { @Override protected void onSubmit() { Comment comment = null; try { comment = ((BlogApplication) getApplication()).getEntityManager().create(Comment.class); } catch (SQLException e) { e.printStackTrace(); return; } comment.setName(commentBean.getName()); comment.setComment(commentBean.getComment()); comment.setPost(post); comments.setList(Arrays.asList(post.getComments())); comments.modelChanged(); } }; add(commentForm); commentForm.add(new TextField("name", new PropertyModel(commentBean, "name"))); commentForm.add(new TextArea("commentText", new PropertyModel(commentBean, "comment"))); }
From source file:org.cast.isi.page.StudentToc.java
License:Open Source License
/** * Returns a list view of the pages in a section. Override * and return an invisible component to hide pages. * //from w ww .ja v a 2 s .com * @param id wicket id of component * @param list list of XmlSections that are pages * @return */ public WebMarkupContainer getPageList(String id, List<XmlSection> list) { ListView<XmlSection> listView = new ListView<XmlSection>(id) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<XmlSection> item) { XmlSection sec3 = item.getModelObject(); ContentLoc loc = new ContentLoc(sec3); BookmarkablePageLink<ISIStandardPage> link = new SectionLinkFactory().linkToPage("link", sec3); if (locsWithUnread.contains(loc.getLocation())) link.add(new Icon("messageIcon", "img/icons/envelope_new.png")); else if (locsWithMessages.contains(loc.getLocation())) link.add(new Icon("messageIcon", "img/icons/envelope_old.png")); else link.add(new WebMarkupContainer("messageIcon").setVisible(false)); item.add(link); link.add(new Label("number", String.valueOf(++pageNum)).setRenderBodyOnly(true)); } }; if (list == null || list.isEmpty()) listView.setVisible(false); else listView.setList(list); return listView; }
From source file:org.onehippo.forge.documenttranslationpicker.DocumentTranslationPickerDialog.java
License:Apache License
public DocumentTranslationPickerDialog(DocumentTranslationPickerWorkflow invoker) { super(invoker.getModel(), invoker); try {//from ww w. j a va 2s. c om this.documentHandle = invoker.getModel().getNode(); try { folders = getTranslations(documentHandle); } catch (RepositoryException e) { LOG.error("Failed to getTranslations", e); } ListView<TranslationOption> listView = new TranslationOptionsListView("options", invoker.getLocaleProvider()); listView.setList(folders); form.add(listView); String introductionResource; if (folders.isEmpty()) { form.setVisible(false); introductionResource = "introduction.withoutOptions"; } else if (folders.size() == 1) { introductionResource = "introduction.withOneOption"; } else { introductionResource = "introduction.withOptions"; } StringResourceModel introductionText = new StringResourceModel(introductionResource, this, null); holder.add(new Label("introduction", introductionText)); holder.add(form); add(holder); } catch (RepositoryException e1) { LOG.error("Failed to create DocumentTranslationPickerDialog", e1); holder.setVisible(false); } }