List of usage examples for org.apache.wicket.markup.html.list ListView ListView
public ListView(final String id)
From source file:ca.travelagency.salesreports.SalesSummaryPanel.java
License:Apache License
public SalesSummaryPanel(String id, SalesSearch salesSearch) { super(id, new CompoundPropertyModel<InvoiceSales>(InvoiceSalesModel.make(salesSearch))); ListView<MonthlyDistribution> listView = new ListView<MonthlyDistribution>( InvoiceSales.Properties.monthlyDistribution.name()) { private static final long serialVersionUID = 1L; @Override// ww w . ja va 2s .com protected ListItem<MonthlyDistribution> newItem(int index, IModel<MonthlyDistribution> itemModel) { return new OddEvenListItem<MonthlyDistribution>(index, itemModel); } @Override protected void populateItem(final ListItem<MonthlyDistribution> item) { item.setModel(new CompoundPropertyModel<MonthlyDistribution>(item.getModelObject())); item.add(new Label(MonthlyDistribution.Properties.dateAsString.name())); Link<Void> link = new Link<Void>(LINK_TO_INVOICES) { private static final long serialVersionUID = 1L; @Override public void onClick() { getAuthenticatedSession().clearInvoiceFilter(); InvoiceFilter invoiceFilter = getAuthenticatedSession().getInvoiceFilter(); invoiceFilter.setSystemUser(getSystemUser()); Date date = item.getModelObject().getDate(); invoiceFilter.setInvoiceDateFrom(date); invoiceFilter.setInvoiceDateTo(DateUtils.addDays(DateUtils.addMonths(date, 1), -1)); setResponsePage(new InvoicesPage()); } }; link.add(new Label(MonthlyDistribution.Properties.count.name())); item.add(link); item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR + SalesAmounts.Properties.saleAsString.name())); item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR + SalesAmounts.Properties.costAsString.name())); item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR + SalesAmounts.Properties.commissionAsString.name())); item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR + SalesAmounts.Properties.commissionReceivedAsString.name())); item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR + SalesAmounts.Properties.commissionVerifiedAsString.name())); item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR + SalesAmounts.Properties.taxOnCommissionAsString.name())); item.add(new Label(MonthlyDistribution.Properties.salesAmounts.name() + Condition.SEPARATOR + SalesAmounts.Properties.paidAsString.name())); } }; add(listView); Link<String> downloadLink = new Link<String>(EXPORT_TO_CSV, Model.of(makeCsvOutput())) { private static final long serialVersionUID = 1L; @Override public void onClick() { StringBufferResourceStream resourceStream = new StringBufferResourceStream("text/csv"); resourceStream.append((CharSequence) getDefaultModelObject()); ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(resourceStream) .setFileName("export.csv").setContentDisposition(ContentDisposition.ATTACHMENT); getRequestCycle().scheduleRequestHandlerAfterCurrent(handler); } }; downloadLink.setVisible(!getSales().getMonthlyDistribution().isEmpty()); add(downloadLink); }
From source file:com.googlecode.ounit.MainPage.java
License:Open Source License
public MainPage(PageParameters parameters) { super(parameters); log.debug("MainPage()"); if (getOunitSession() == null) throw new RuntimeException("No model attached to the page"); if (!getOunitSession().isPrepared()) { throw new RuntimeException("Main page requires a prepared session"); }//ww w . j a va 2 s . c o m WebMarkupContainer quizPanel = new WebMarkupContainer("questiondiv"); mainForm.add(quizPanel); quizPanel .add(new QuizStateAttributeModifier(getOunitModel(), "class", "ou-question", "ou-closed-question")); final Component description = new HtmlFile("description"); quizPanel.add(description); quizPanel.add(new AnchorLink("descriptionlink", description)); final Component results = new HtmlFile("resultsFile"); quizPanel.add(results); quizPanel.add(new WebMarkupContainer("resultscaption") { private static final long serialVersionUID = 1L; protected void onConfigure() { super.onConfigure(); results.configure(); setVisible(results.isVisible()); }; }.add(new AnchorLink("resultslink", results))); /* * Generate TextAreas first, because we need editor objects as anchors * for the links */ ListView<ProjectTreeNode> lv = new ListView<ProjectTreeNode>("editors") { private static final long serialVersionUID = 1L; protected void populateItem(ListItem<ProjectTreeNode> item) { ProjectTreeNode node = item.getModelObject(); node.setEditor(item); TextArea<ProjectTreeNode> ta = new TextArea<ProjectTreeNode>("editorarea", new PropertyModel<ProjectTreeNode>(node, "fileContents")); ta.add(AttributeModifier.replace("title", node.getName())); ta.add(new QuizStateAttributeModifier(getOunitModel(), "readonly", null, "readonly")); item.add(ta); item.setOutputMarkupId(true); } }; quizPanel.add(lv); lv.setReuseItems(true); /* Force ListView to populate itself RIGHT NOW so state-less forms can work */ // FIXME: This is an internal function. Maybe implement some hack like this // http://osdir.com/ml/users-wicket.apache.org/2009-02/msg00925.html lv.internalPrepareForRender(false); /* * Populate tab header links */ quizPanel.add(new ListView<ProjectTreeNode>("editorcaptions") { private static final long serialVersionUID = 1L; protected void populateItem(ListItem<ProjectTreeNode> item) { ProjectTreeNode node = item.getModelObject(); item.add(new AnchorLink("editorlink", node.getEditor(), node.getName())); } }.setReuseItems(true)); final Component tree = new ExplorerTreePanel("tree"); quizPanel.add(tree); quizPanel.add(new WebMarkupContainer("treecaption") { private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); tree.configure(); setVisible(tree.isVisible()); } }); // FIXME: We shouldn't access it directly. Should use model or something quizPanel.add(new QuestionDownloadLink("download")); mainForm.add(new Button("compile") { private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); setVisible(!getOunitSession().isClosed()); } @Override public void onSubmit() { // FIXME: This is a hack that should go away as soon as sessions // start working properly redirected = true; setResponsePage(MainPage.class); OunitSession sess = getOunitSession(); // Check if student is out of attempts int attempt = sess.getAttempt(); int maxAttempts = sess.getMaxAttempts(); if (maxAttempts > 0) { if (attempt >= maxAttempts) sess.setClosed(true); /* * Skip build if out of attempts. This is a sanity check, it * shouldn't happen under normal circumstances */ if (attempt > maxAttempts) return; } sess.setAttempt(attempt + 1); boolean buildSuccessful = sess.build(); int marks = sess.getMarks(); if (marks == sess.getMaxMarks()) { // Max marks, grade NOW! sess.setClosed(true); } if (!buildSuccessful && !sess.isClosed()) { // Successful build, ask if student wants a partial grade setResponsePage(ConfirmPage.class); } } }); mainForm.add(new Label("attempt")); mainForm.add(new Label("maxAttempts") { private static final long serialVersionUID = 1L; @Override protected void onConfigure() { super.onConfigure(); if (getOunitSession().isClosed()) { setVisible(false); } else { setVisible(getOunitSession().getMaxAttempts() > 0); } } }); }
From source file:com.googlecode.wicketelements.components.menu.MenuPanel.java
License:Apache License
private void populateRepeatingView(final PageTreeModel pages) { final ListView<Class<Page>> lv = new ListView<Class<Page>>("breadcrumbs") { private static final long serialVersionUID = 1L; @Override//w w w . j av a 2s. c om protected void populateItem(final ListItem<Class<Page>> item) { final Class<Page> pageClass = item.getModelObject(); { final Link<Class<Page>> link = new BookmarkablePageLink<Class<Page>>("breadcrumbLink", pageClass) { private static final long serialVersionUID = 1L; @Override protected void onBeforeRender() { super.onBeforeRender(); if (pageClass.equals(getPage().getClass())) { onPageLink(this); onCurrentPageLink(this); } else { onPageLink(this); } } }; { final Label languageLabel = new Label("breadcrumbLabel", "hard label" /*TODO get localized label from somewhere...*/); languageLabel.setRenderBodyOnly(true); link.add(languageLabel); } item.add(link); } item.setOutputMarkupId(true); } }; lv.setRenderBodyOnly(true); add(lv); }
From source file:com.marc.lastweek.web.pages.classifiedadslisting.FilterResultsPage.java
License:Open Source License
public FilterResultsPage(PageParameters parameters) { super(parameters); boolean hasCategory = false; boolean hasSubcategory = false; boolean hasProvince = false; final FilterParameters filterParameters = new FilterParameters(); int paramCounter = 0; if (parameters.get(PageParametersNaming.PARAM_NAME_SEARCH_TERM) != null) { paramCounter++;/* www . j a v a 2 s . c om*/ filterParameters.setSearchString(StringEscapeUtils .unescapeHtml(parameters.getString(PageParametersNaming.PARAM_NAME_SEARCH_TERM))); } if (parameters.get(PageParametersNaming.PARAM_NAME_CATEGORY_ID) != null) { hasCategory = true; paramCounter++; this.categoryName = parameters.getString(PageParametersNaming.PARAM_NAME_CATEGORY_NAME); filterParameters .setCategoryId(new Long(parameters.getLong(PageParametersNaming.PARAM_NAME_CATEGORY_ID))); } if (parameters.get(PageParametersNaming.PARAM_NAME_SUBCATEGORY_ID) != null) { hasSubcategory = true; paramCounter++; this.subcategoryName = parameters.getString(PageParametersNaming.PARAM_NAME_SUBCATEGORY_NAME); filterParameters .setSubcategoryId(new Long(parameters.getLong(PageParametersNaming.PARAM_NAME_SUBCATEGORY_ID))); } if (parameters.get(PageParametersNaming.PARAM_NAME_PROVINCE_ID) != null) { hasProvince = true; paramCounter++; this.provinceName = parameters.getString(PageParametersNaming.PARAM_NAME_PROVINCE_NAME); filterParameters .setProvinceId(new Long(parameters.getLong(PageParametersNaming.PARAM_NAME_PROVINCE_ID))); } if (paramCounter == 0) { setResponsePage(LastweekApplication.get().getHomePage()); } this.addFilterParametersToHistory(filterParameters); /* * The results panel */ this.add(new ClassifiedAdsListPanel("classifiedAdsPanel", filterParameters)); /* * The filter parameters panel */ this.add(new FilterParametersPanel("filterParameters", parameters)); /* * Propaganda boxes */ this.add(new CreateNewAdPropagandaPanel("createNewAd")); /* * Categories */ WebMarkupContainer categoriesDiv = new WebMarkupContainer("categoriesDiv"); ListView categoiresList = new ListView("categoriesList") { private static final long serialVersionUID = -5142681180212487928L; @Override protected void populateItem(ListItem listItem) { Category category = (Category) listItem.getModelObject(); PageParameters linkParameters = new PageParameters(); linkParameters.put(PageParametersNaming.PARAM_NAME_CATEGORY_ID, category.getId()); linkParameters.put(PageParametersNaming.PARAM_NAME_CATEGORY_NAME, StringEscapeUtils.escapeHtml(category.getName())); if (filterParameters.getSearchString() != null) { linkParameters.put(PageParametersNaming.PARAM_NAME_SEARCH_TERM, filterParameters.getSearchString()); } if (filterParameters.getProvinceId() != null) { linkParameters.put(PageParametersNaming.PARAM_NAME_PROVINCE_ID, filterParameters.getProvinceId()); linkParameters.put(PageParametersNaming.PARAM_NAME_PROVINCE_NAME, ViewUtils.normalize(FilterResultsPage.this.provinceName)); } BookmarkablePageLink categoryLink = new BookmarkablePageLink("categoryLink", FilterResultsPage.class, linkParameters); categoryLink.add(new Label("categoryName", category.getName())); listItem.add(categoryLink); } }; if (!hasCategory) { categoiresList.setModel(new LoadableCategoriesListModel()); } else { categoriesDiv.setVisible(false); } categoriesDiv.add(categoiresList); this.add(categoriesDiv); /* * Provinces */ WebMarkupContainer provincesDiv = new WebMarkupContainer("provincesDiv"); ListView provincesList = new ListView("provincesList") { private static final long serialVersionUID = -5843308083402561880L; @Override protected void populateItem(ListItem listItem) { Province province = (Province) listItem.getModelObject(); PageParameters linkParameters = new PageParameters(); linkParameters.put(PageParametersNaming.PARAM_NAME_PROVINCE_ID, province.getId()); linkParameters.put(PageParametersNaming.PARAM_NAME_PROVINCE_NAME, StringEscapeUtils.escapeHtml(province.getName())); if (filterParameters.getSearchString() != null) { linkParameters.put(PageParametersNaming.PARAM_NAME_SEARCH_TERM, filterParameters.getSearchString()); } if (filterParameters.getCategoryId() != null) { linkParameters.put(PageParametersNaming.PARAM_NAME_CATEGORY_ID, filterParameters.getCategoryId()); linkParameters.put(PageParametersNaming.PARAM_NAME_CATEGORY_NAME, FilterResultsPage.this.categoryName); } if (filterParameters.getSubcategoryId() != null) { linkParameters.put(PageParametersNaming.PARAM_NAME_SUBCATEGORY_ID, filterParameters.getSubcategoryId()); linkParameters.put(PageParametersNaming.PARAM_NAME_SUBCATEGORY_NAME, FilterResultsPage.this.subcategoryName); } BookmarkablePageLink provinceLink = new BookmarkablePageLink("provinceLink", FilterResultsPage.class, linkParameters); provinceLink.add(new Label("provinceName", province.getName())); if (listItem.getIndex() % 2 == 1) { listItem.add(new SimpleAttributeModifier("class", "parallel-column")); } listItem.add(provinceLink); } }; if (!hasProvince) { provincesList.setModel(new LoadableProvincesListModel()); } else { provincesDiv.setVisible(false); } provincesDiv.add(provincesList); this.add(provincesDiv); /* * Subcategories */ WebMarkupContainer subcategoriesDiv = new WebMarkupContainer("subcategoriesDiv"); ListView subcategoriesList = new ListView("subcategoriesList") { private static final long serialVersionUID = -5142681180212487928L; @Override protected void populateItem(ListItem listItem) { Subcategory subcategory = (Subcategory) listItem.getModelObject(); PageParameters linkParameters = new PageParameters(); linkParameters.put(PageParametersNaming.PARAM_NAME_SUBCATEGORY_ID, subcategory.getId()); linkParameters.put(PageParametersNaming.PARAM_NAME_SUBCATEGORY_NAME, StringEscapeUtils.escapeHtml(subcategory.getName())); if (filterParameters.getSearchString() != null) { linkParameters.put(PageParametersNaming.PARAM_NAME_SEARCH_TERM, filterParameters.getSearchString()); } if (filterParameters.getCategoryId() != null) { linkParameters.put(PageParametersNaming.PARAM_NAME_CATEGORY_ID, filterParameters.getCategoryId()); linkParameters.put(PageParametersNaming.PARAM_NAME_CATEGORY_NAME, FilterResultsPage.this.categoryName); } if (filterParameters.getProvinceId() != null) { linkParameters.put(PageParametersNaming.PARAM_NAME_PROVINCE_ID, filterParameters.getProvinceId()); linkParameters.put(PageParametersNaming.PARAM_NAME_PROVINCE_NAME, FilterResultsPage.this.provinceName); } BookmarkablePageLink subcategoryLink = new BookmarkablePageLink("subcategoryLink", FilterResultsPage.class, linkParameters); subcategoryLink.add(new Label("subcategoryName", subcategory.getName())); listItem.add(subcategoryLink); } }; if (!hasSubcategory && hasCategory) { subcategoriesList.setModel(new LoadableSubcategoriesListModel(filterParameters.getCategoryId())); } else { subcategoriesDiv.setVisible(false); } subcategoriesDiv.add(subcategoriesList); this.add(subcategoriesDiv); }
From source file:com.przemo.busessearch.panels.SearchResultsPanel.java
private void buildPanel() { ListView<Lines> lv = new ListView<Lines>("result") { @Override//from w ww.j ava2 s .co m protected void populateItem(ListItem item) { Lines line = (Lines) item.getModelObject(); item.add(new Label("id", line.getId())); item.add(new Label("decription", line.getDecription())); } }; add(lv); }
From source file:com.tysanclan.site.projectewok.components.TysanOverviewPanel.java
License:Open Source License
protected TysanOverviewPanel(String id, IModel<T> model, String title) { super(id);//from www.ja va2s .co m this.model = model; this.notifications = new LinkedList<String>(); add(new Label("title", title)); add(new ListView<String>("states") { private static final long serialVersionUID = 1L; /** * @see org.apache.wicket.markup.html.list.ListView#populateItem(org.apache.wicket.markup.html.list.ListItem) */ @Override protected void populateItem(ListItem<String> item) { item.add(new ContextImage("icanhaznotification", "images/icons/error.png")); } }); }
From source file:com.userweave.module.methoden.questionnaire.page.grouping.multiplepossibleanswers.MultiplePossibleAnswersGroupingDescriptionPanel.java
License:Open Source License
public MultiplePossibleAnswersGroupingDescriptionPanel(String id, IModel groupModel, final Locale locale) { super(id);/* w w w .j ava2s . c om*/ setDefaultModel(new CompoundPropertyModel(groupModel)); add(new Label("name")); add(new Label("question", new LocalizedPropertyModel(groupModel, "question.name", locale))); add(new ListView("answers") { @Override protected void populateItem(ListItem item) { item.add(new Label("answer", new LocalizedModel((Serializable) item.getModelObject(), locale))); item.add(new Label("separator", item.getIndex() > 0 ? ", " : "")); } }); }
From source file:com.userweave.pages.grouping.StudyLocalesGroupingDescriptionPanel.java
License:Open Source License
public StudyLocalesGroupingDescriptionPanel(String id, IModel groupModel, final Locale locale) { super(id);/* w w w.ja v a 2 s .co m*/ setDefaultModel(new CompoundPropertyModel(groupModel)); add(new Label("name")); add(new ListView("locales") { @Override protected void populateItem(ListItem item) { item.add(new Label("locale", item.getModelObject().toString())); item.add(new Label("separator", item.getIndex() > 0 ? ", " : "")); } }); }
From source file:cz.muni.exceptions.web.pages.ExceptionDetailPage.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); add(new Label("detailMessage")); add(new Label("className")); add(new Label("stackTrace")); add(new Label("ticketClass")); add(new ListView<TicketOccurrence>("occurrences") { @Override//from w ww . j av a 2s .co m protected void populateItem(ListItem<TicketOccurrence> item) { item.add(new TicketOccurrenceLabel("occurrence", item.getModelObject())); } }); add(new Link<Void>("back") { @Override public void onClick() { setResponsePage(ExceptionsPage.class); } }); }
From source file:de.elatexam.editor.components.panels.tasks.mapping.MappingPreviewPanel.java
License:Open Source License
@Override protected void onInitialize() { super.onInitialize(); MappingSubTaskDef mstd = (MappingSubTaskDef) getDefaultModelObject(); final List<Assignment> ass = mstd.getAssignment(); add(new ListView<Concept>("concept") { @Override/*from w w w.j ava 2s.c o m*/ protected void populateItem(ListItem<Concept> item) { item.add(new Label("name", item.getModelObject().getName()).setEscapeModelStrings(false)); item.add(new DropDownChoice<Assignment>("assignment", ass) { @Override public IConverter getConverter(Class type) { return new IConverter() { @Override public String convertToString(Object value, Locale locale) { return ((Assignment) value).getName(); } @Override public Object convertToObject(String value, Locale locale) { return null; } }; } }); } }); }