List of usage examples for org.apache.wicket.model CompoundPropertyModel CompoundPropertyModel
public CompoundPropertyModel(final T object)
From source file:almira.sample.web.IndexPage.java
License:Apache License
/** * Constructor.// w w w.j a v a2s . c o m */ public IndexPage() { super(); final Catapult catapult = new Catapult(); final CompoundPropertyModel<Catapult> model = new CompoundPropertyModel<Catapult>(catapult); CATAPULT_CREATION_FORM.setModel(model); add(CATAPULT_CREATION_FORM); // add feedback panel to display any feedback messages for this form add(new FeedbackPanel("feedback", new ContainerFeedbackMessageFilter(CATAPULT_CREATION_FORM))); }
From source file:almira.sample.web.SearchResultPanel.java
License:Apache License
/** * Constructor./*from ww w .ja v a 2s . c o m*/ * * @param id component id * @param searchQuery the search query */ public SearchResultPanel(String id, String searchQuery) { super(id); IDataProvider<Catapult> dataProvider; if (searchQuery == null) { dataProvider = new CatapultListDataProvider(catapultQueryService); } else { dataProvider = new CatapultSearchDataProvider(catapultQueryService, searchQuery); } DataView<Catapult> dataView = new DataView<Catapult>("rows", dataProvider, ITEMS_PER_PAGE) { @Override protected void populateItem(Item<Catapult> item) { final Catapult catapult = item.getModelObject(); item.setModel(new CompoundPropertyModel<Catapult>(catapult)); item.add(new Label("id")); item.add(new Label("name")); item.add(new Label("created")); item.add(new Label("lastModified")); item.add(new Link<Catapult>("delete", item.getModel()) { @Override public void onClick() { // Detached object: Need to delete by ID! catapultUpdateService.delete(catapult.getId()); } }); } }; add(dataView); add(new PagingNavigator("footerPaginator", dataView)); }
From source file:almira.sample.web.ShowCatapultPage.java
License:Apache License
/** * Constructor./*from ww w . ja v a 2 s.c o m*/ * * @param params the page parameters */ public ShowCatapultPage(PageParameters params) { super(); final String id = params.get("catapultId").toString(); Catapult catapult = catapultLoadService.load(Long.parseLong(id)); setDefaultModel(new CompoundPropertyModel<Catapult>(catapult)); add(new Label("id")); add(new Label("name")); add(new Label("created")); add(new Label("lastModified")); }
From source file:at.ac.tuwien.ifs.tita.ui.evaluation.timeconsumer.DailyViewPage.java
License:Apache License
/** * Inits Page./*from w w w .j av a 2 s .co m*/ */ private void initPage() { Form<Effort> form = new Form<Effort>("timeConsumerEvaluationForm", new CompoundPropertyModel<Effort>(new Effort())); add(form); form.setOutputMarkupId(true); final DateTextField dateTextField = new DateTextField("tedate", new PropertyModel<Date>(this, "date"), new StyleDateConverter("S-", true)); dateTextField.add(new DatePicker()); form.add(dateTextField); final WebMarkupContainer timeeffortContainer = new WebMarkupContainer("timeeffortContainer"); timeeffortContainer.setOutputMarkupId(true); timeeffortContainer.setOutputMarkupPlaceholderTag(true); add(timeeffortContainer); tableModel = new TableModelTimeConsumerEvaluation(getTimeEffortsDailyView(new Date())); Table table = new Table("tetable", tableModel); timeeffortContainer.add(table); final Button btnShowAsPDF = new Button("btnShowPDF") { @Override public void onSubmit() { try { loadReport(); ResourceStreamRequestTarget rsrtarget = new ResourceStreamRequestTarget( pdfResource.getResourceStream()); rsrtarget.setFileName(pdfResource.getFilename()); RequestCycle.get().setRequestTarget(rsrtarget); } catch (JRException e) { // TODO: GUI Exception Handling log.error(e.getMessage()); } catch (PersistenceException e) { // TODO: GUI Exception Handling log.error(e.getMessage()); } } @Override public boolean isEnabled() { return tableModel.getRowCount() == 0 ? false : true; } }; form.add(btnShowAsPDF); form.add(new AjaxButton("btnShowEvaluation", form) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form1) { tableModel.reload(getTimeEffortsDailyView(dateTextField.getModelObject())); target.addComponent(timeeffortContainer); target.addComponent(btnShowAsPDF); } @Override protected void onError(AjaxRequestTarget target, Form<?> form1) { // TODO Set border red on textfields which are'nt filled } }); }
From source file:at.ac.tuwien.ifs.tita.ui.evaluation.timeconsumer.MonthlyViewPage.java
License:Apache License
/** * Inits Page.//w w w .j a va 2s. c om */ @SuppressWarnings("unchecked") private void initPage() { Form<Effort> form = new Form<Effort>("timeConsumerEvaluationForm", new CompoundPropertyModel<Effort>(new Effort())); add(form); form.setOutputMarkupId(true); ChoiceRenderer choiceRenderer = new ChoiceRenderer("value", "key"); final DropDownChoice ddYears = new DropDownChoice("yearSelection", new PropertyModel(this, "selectedYear"), getYears(), choiceRenderer); form.add(ddYears); final DropDownChoice ddMonths = new DropDownChoice("monthSelection", new PropertyModel(this, "selectedMonth"), getMonths(), choiceRenderer); form.add(ddMonths); final WebMarkupContainer timeeffortContainer = new WebMarkupContainer("timeeffortContainer"); timeeffortContainer.setOutputMarkupId(true); timeeffortContainer.setOutputMarkupPlaceholderTag(true); add(timeeffortContainer); initButtons(form, timeeffortContainer); Calendar cal = Calendar.getInstance(); tableModel = new TableModelTimeConsumerEvaluation( getTimeEffortsMonthlyView(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH))); Table table = new Table("tetable", tableModel); timeeffortContainer.add(table); }
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/*from ww w. jav a 2 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); } }); }
From source file:au.org.theark.admin.web.component.activitymonitor.ActivityMonitorContainerPanel.java
License:Open Source License
/** * @param id/* ww w .j av a 2 s .c om*/ */ public ActivityMonitorContainerPanel(String id) { super(id); form = new Form<ActivityMonitorVO>("form", new CompoundPropertyModel<ActivityMonitorVO>(new ActivityMonitorVO())); form.add(initialiseFeedBackPanel()); form.add(initialiseSearchResults()); refresh = new AjaxButton("refresh") { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, Form<?> form) { log.error("Error on refresh click"); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { target.add(searchResultsPanel); } }; refresh.setDefaultFormProcessing(false); form.add(refresh); add(form); }
From source file:au.org.theark.admin.web.component.function.FunctionContainerPanel.java
License:Open Source License
/** * @param id/*from w ww .j a v a2 s.c o m*/ */ public FunctionContainerPanel(String id) { super(id); /* Initialise the CPM */ cpModel = new CompoundPropertyModel<AdminVO>(new AdminVO()); initCrudContainerVO(); /* Bind the CPM to the Form */ containerForm = new ContainerForm("containerForm", cpModel); containerForm.add(initialiseFeedBackPanel()); containerForm.add(initialiseDetailPanel()); containerForm.add(initialiseSearchPanel()); containerForm.add(initialiseSearchResults()); add(containerForm); }
From source file:au.org.theark.admin.web.component.module.ModuleContainerPanel.java
License:Open Source License
/** * @param id// ww w. ja v a 2s .c om */ public ModuleContainerPanel(String id) { super(id); /* Initialise the CPM */ cpModel = new CompoundPropertyModel<AdminVO>(new AdminVO()); initCrudContainerVO(); /* Bind the CPM to the Form */ containerForm = new ContainerForm("containerForm", cpModel); containerForm.add(initialiseFeedBackPanel()); containerForm.add(initialiseDetailPanel()); containerForm.add(initialiseSearchPanel()); containerForm.add(initialiseSearchResults()); add(containerForm); }
From source file:au.org.theark.admin.web.component.modulefunction.ModuleFunctionContainerPanel.java
License:Open Source License
/** * @param id/*from w w w.j a v a2s . c o m*/ */ public ModuleFunctionContainerPanel(String id) { super(id); /* Initialise the CPM */ cpModel = new CompoundPropertyModel<AdminVO>(new AdminVO()); initCrudContainerVO(); /* Bind the CPM to the Form */ containerForm = new ContainerForm("containerForm", cpModel); containerForm.add(initialiseFeedBackPanel()); containerForm.add(initialiseDetailPanel()); containerForm.add(initialiseSearchPanel()); containerForm.add(initialiseSearchResults()); add(containerForm); }