List of usage examples for org.apache.wicket.model AbstractReadOnlyModel AbstractReadOnlyModel
AbstractReadOnlyModel
From source file:at.ac.tuwien.ifs.tita.ui.TitaDataProvider.java
License:Apache License
/** * TODO: write javadoc./*from www . j a v a 2 s .co m*/ * * @param object x * @return x */ public IModel<T> model(final T object) { return new AbstractReadOnlyModel<T>() { @Override public T getObject() { return object; } }; }
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 w ww . j a v a 2 s . c o 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.SearchResultsPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public PageableListView<ArkSubjectSessionVO> buildPageableListView(IModel iModel) { PageableListView<ArkSubjectSessionVO> pageableListView = new PageableListView<ArkSubjectSessionVO>("list", iModel,//w w w . j a va 2 s . c o m iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<ArkSubjectSessionVO> item) { final ArkSubjectSessionVO subject = (ArkSubjectSessionVO) item.getModelObject(); final String sessionId = subject.getSessionId(); final String userId = subject.getUserId(); final String host = subject.getHost(); final Date startTimestamp = subject.getStartTimestamp(); final Date lastAccessTime = subject.getLastAccessTime(); SimpleDateFormat sdf = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY_HH_MM_SS); item.add(new Label(au.org.theark.core.Constants.ARK_SESSION_ID, sessionId)); item.add(new Label(au.org.theark.core.Constants.ARK_USERID, userId)); item.add(new Label(au.org.theark.core.Constants.ARK_HOST, host)); item.add(new Label(au.org.theark.core.Constants.ARK_SESSION_START_TIMESTAMP, sdf.format(startTimestamp))); item.add(new Label(au.org.theark.core.Constants.ARK_SESSION_LAST_ACCESS_TIME, sdf.format(lastAccessTime))); item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1938679383897533820L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return pageableListView; }
From source file:au.org.theark.admin.web.component.function.SearchResultsPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public DataView<ArkFunction> buildDataView(ArkDataProvider<ArkFunction, IAdminService> dataProvider) { DataView<ArkFunction> dataView = new DataView<ArkFunction>("arkFunctionList", dataProvider) { private static final long serialVersionUID = 2981419595326128410L; @Override//from w w w.j a va2 s . c om protected void populateItem(final Item<ArkFunction> item) { ArkFunction arkFunction = item.getModelObject(); item.add(new Label("arkFunction.id", arkFunction.getId().toString())); item.add(buildLink(arkFunction)); if (arkFunction.getDescription() != null) { // the ID here must match the ones in mark-up item.add(new Label("arkFunction.description", arkFunction.getDescription())); } else { item.add(new Label("arkFunction.description", "")); } if (arkFunction.getArkFunctionType() != null) { // the ID here must match the ones in mark-up item.add(new Label("arkFunction.arkFunctionType", arkFunction.getArkFunctionType().getName())); } else { item.add(new Label("arkFunction.arkFunctionType", "")); } item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 5761909841047153853L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return dataView; }
From source file:au.org.theark.admin.web.component.function.SearchResultsPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public PageableListView<ArkFunction> buildPageableListView(IModel iModel, final WebMarkupContainer searchResultsContainer) { PageableListView<ArkFunction> pageableListView = new PageableListView<ArkFunction>("arkFunctionList", iModel,/*from w w w .j av a 2 s. c om*/ iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) { private static final long serialVersionUID = 3350183112731574263L; @Override protected void populateItem(final ListItem<ArkFunction> item) { ArkFunction arkFunction = item.getModelObject(); item.add(buildLink(arkFunction)); if (arkFunction.getName() != null) { // the ID here must match the ones in mark-up item.add(new Label("arkFunction.name", arkFunction.getName())); } else { item.add(new Label("arkFunction.name", "")); } if (arkFunction.getDescription() != null) { // the ID here must match the ones in mark-up item.add(new Label("arkFunction.description", arkFunction.getDescription())); } else { item.add(new Label("arkFunction.description", "")); } if (arkFunction.getArkFunctionType() != null) { // the ID here must match the ones in mark-up item.add(new Label("arkFunction.arkFunctionType", arkFunction.getArkFunctionType().getName())); } else { item.add(new Label("arkFunction.arkFunctionType", "")); } item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1938679383897533820L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return pageableListView; }
From source file:au.org.theark.admin.web.component.module.SearchResultsPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public DataView<ArkModule> buildDataView(ArkDataProvider<ArkModule, IAdminService> dataProvider) { DataView<ArkModule> dataView = new DataView<ArkModule>("arkModuleList", dataProvider) { private static final long serialVersionUID = 2981419595326128410L; @Override//from www . j a va 2 s. c o m protected void populateItem(final Item<ArkModule> item) { ArkModule arkModule = item.getModelObject(); item.add(new Label("arkModule.id", arkModule.getId().toString())); item.add(buildLink(arkModule)); if (arkModule.getDescription() != null) { // the ID here must match the ones in mark-up item.add(new Label("arkModule.description", arkModule.getDescription())); } else { item.add(new Label("arkModule.description", "")); } item.add(new Label("arkModule.enabled", arkModule.getEnabled() ? "Enabled" : "Disabled")); item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 5761909841047153853L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return dataView; }
From source file:au.org.theark.admin.web.component.module.SearchResultsPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public PageableListView<ArkModule> buildPageableListView(IModel iModel, final WebMarkupContainer searchResultsContainer) { PageableListView<ArkModule> pageableListView = new PageableListView<ArkModule>("arkModuleList", iModel, iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()) { private static final long serialVersionUID = 3350183112731574263L; @Override//from w ww . ja v a 2 s . c om protected void populateItem(final ListItem<ArkModule> item) { ArkModule arkModule = item.getModelObject(); item.add(buildLink(arkModule)); if (arkModule.getName() != null) { // the ID here must match the ones in mark-up item.add(new Label("arkModule.name", arkModule.getName())); } else { item.add(new Label("arkModule.name", "")); } if (arkModule.getDescription() != null) { // the ID here must match the ones in mark-up item.add(new Label("arkModule.description", arkModule.getDescription())); } else { item.add(new Label("arkModule.description", "")); } item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1938679383897533820L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return pageableListView; }
From source file:au.org.theark.admin.web.component.modulefunction.SearchResultsPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public DataView<ArkModuleFunction> buildDataView( ArkDataProvider<ArkModuleFunction, IAdminService> dataProvider) { DataView<ArkModuleFunction> dataView = new DataView<ArkModuleFunction>("arkModuleFunctionList", dataProvider) {/*from www .j ava 2s . co m*/ private static final long serialVersionUID = 2981419595326128410L; @Override protected void populateItem(final Item<ArkModuleFunction> item) { ArkModuleFunction arkModuleFunction = item.getModelObject(); item.add(new Label("arkModuleFunction.id", arkModuleFunction.getId().toString())); item.add(buildLink(arkModuleFunction)); if (arkModuleFunction.getArkFunction() != null) { item.add(new Label("arkModuleFunction.arkFunction", arkModuleFunction.getArkFunction().getName())); } else { item.add(new Label("arkModuleFunction.arkFunction", "")); } if (arkModuleFunction.getFunctionSequence() != null) { item.add(new Label("arkModuleFunction.functionSequence", arkModuleFunction.getFunctionSequence().toString())); } else { item.add(new Label("arkModuleFunction.functionSequence", "")); } item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 5761909841047153853L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return dataView; }
From source file:au.org.theark.admin.web.component.modulerole.SearchResultsPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public DataView<ArkModuleRole> buildDataView(ArkDataProvider<ArkModuleRole, IAdminService> dataProvider) { DataView<ArkModuleRole> dataView = new DataView<ArkModuleRole>("arkModuleRoleList", dataProvider) { private static final long serialVersionUID = 1L; @Override/* www. j a v a 2 s .c o m*/ protected void populateItem(final Item<ArkModuleRole> item) { ArkModuleRole arkModuleRole = item.getModelObject(); item.add(new Label("arkModuleRole.id", arkModuleRole.getId().toString())); item.add(buildLink(arkModuleRole)); if (arkModuleRole.getArkRole() != null) { item.add(new Label("arkModuleRole.arkRole", arkModuleRole.getArkRole().getName())); } else { item.add(new Label("arkModuleRole.arkRole", "")); } item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 5761909841047153853L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return dataView; }
From source file:au.org.theark.admin.web.component.role.SearchResultsPanel.java
License:Open Source License
@SuppressWarnings("unchecked") public DataView<ArkRole> buildDataView(ArkDataProvider<ArkRole, IAdminService> dataProvider) { DataView<ArkRole> dataView = new DataView<ArkRole>("arkRoleList", dataProvider) { private static final long serialVersionUID = 2981419595326128410L; @Override/* w w w. ja v a2 s. c om*/ protected void populateItem(final Item<ArkRole> item) { ArkRole arkRole = item.getModelObject(); item.add(new Label("arkRole.id", arkRole.getId().toString())); item.add(buildLink(arkRole)); if (arkRole.getDescription() != null) { // the ID here must match the ones in mark-up item.add(new Label("arkRole.description", arkRole.getDescription())); } else { item.add(new Label("arkRole.description", "")); } item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 5761909841047153853L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return dataView; }