List of usage examples for org.apache.wicket.markup.html.list ListItem getModel
@SuppressWarnings("unchecked") default IModel<T> getModel()
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 . 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.core.web.component.panel.table.DataTablePanel.java
License:Open Source License
private void initBody() { // Using a nested ListViews //TODO Constant for page size PageableListView<List<String>> listView = new PageableListView<List<String>>("data", data, 15) { private static final long serialVersionUID = 1L; @Override/* w w w.ja va 2 s .c o m*/ protected void populateItem(ListItem<List<String>> item) { IModel model = item.getModel(); item.add(new ListView<String>("cols", model) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<String> item) { item.add(new Label("value", item.getModelObject())); } }); } }; table.add(listView); add(new PagingNavigator("navigator", listView)); }
From source file:au.org.theark.study.web.component.mydetails.form.MyDetailsForm.java
License:Open Source License
@SuppressWarnings({ "unchecked" })
public void initialiseForm() {
//ArkUserVO arkUserVOFromBackend = new ArkUserVO();
try {/* www . j a va 2 s .c o m*/
ArkUserVO arkUserVOFromBackend = iUserService.lookupArkUser(getModelObject().getUserName(),
getModelObject().getStudy());
Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession()
.getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID);
if (sessionStudyId != null) {
arkUserVOFromBackend.setStudy(iArkCommonService.getStudy(sessionStudyId));
} else {
arkUserVOFromBackend.setStudy(getModelObject().getStudy());
}
//Study will selected with model object and that will be the page list view accordingly.
listViewPanel.setOutputMarkupId(true);
iModel = new LoadableDetachableModel() {
private static final long serialVersionUID = 1L;
@Override
protected Object load() {
return getModelObject().getArkRolePolicyTemplatesList();
}
};
initStudyDdc(arkUserVOFromBackend);
List<UserConfig> arkUserConfigs = iArkCommonService
.getUserConfigs(arkUserVOFromBackend.getArkUserEntity());
arkUserVOFromBackend.setArkUserConfigs(arkUserConfigs);
getModelObject().setArkUserConfigs(arkUserConfigs);
} catch (ArkSystemException e) {
log.error(e.getMessage());
}
emailTxtField.setOutputMarkupId(true);
saveButton = new AjaxButton(Constants.SAVE) {
private static final long serialVersionUID = -8737230044711628981L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
onSave(target);
}
public void onError(AjaxRequestTarget target, Form<?> form) {
processFeedback(target, feedbackPanel);
}
};
closeButton = new AjaxButton(Constants.CLOSE) {
private static final long serialVersionUID = 5457464178392550628L;
public void onSubmit(AjaxRequestTarget target, Form<?> form) {
modalWindow.close(target);
}
public void onError(AjaxRequestTarget target, Form<?> form) {
processFeedback(target, feedbackPanel);
}
};
closeButton.setDefaultFormProcessing(false);
emailTxtField.add(EmailAddressValidator.getInstance());
boolean loggedInViaAAF = ((String) SecurityUtils.getSubject().getSession()
.getAttribute(au.org.theark.core.Constants.SHIB_SESSION_ID) != null);
groupPasswordContainer.setVisible(!loggedInViaAAF);
shibbolethSessionDetails
.add(new AttributeModifier("src", ArkShibbolethServiceProviderContextSource.handlerUrl
+ ArkShibbolethServiceProviderContextSource.session));
shibbolethSession.add(new AttributeModifier("class", "paddedDetailPanel"));
shibbolethSession.setVisible(loggedInViaAAF);
shibbolethSession.add(shibbolethSessionDetails);
userConfigListEditor = new AbstractListEditor<UserConfig>("arkUserConfigs") {
@Override
protected void onPopulateItem(au.org.theark.core.web.component.listeditor.ListItem<UserConfig> item) {
item.add(new Label("configField.description",
item.getModelObject().getConfigField().getDescription()));
PropertyModel<String> propModel = new PropertyModel<String>(item.getModel(), "value");
TextField<String> valueTxtFld = new TextField<String>("value", propModel);
item.add(valueTxtFld);
item.add(new AttributeModifier("class", new AbstractReadOnlyModel() {
private static final long serialVersionUID = -8887455455175404701L;
@Override
public String getObject() {
return (item.getIndex() % 2 == 1) ? "even" : "odd";
}
}));
}
};
attachValidators();
addComponents();
}
From source file:ca.travelagency.components.formdetail.DetailsPanel.java
License:Apache License
public DetailsPanel(String id, IModel<T> model) { super(id, model); setOutputMarkupId(true);/*from w w w . j av a 2s .co m*/ webMarkupContainer = new WebMarkupContainer(ROWS_CONTAINER); webMarkupContainer.setOutputMarkupId(true); add(webMarkupContainer); webMarkupContainer.add(makeDetailFormPanel(FORM).setVisible(isEditable())); webMarkupContainer.add(makeDetailHeaderPanel(HEADER)); LoadableDetachableModel<List<D>> listModel = new LoadableDetachableModel<List<D>>() { private static final long serialVersionUID = 1L; @Override protected List<D> load() { return getDetails(); } }; details = new ListView<D>(ROWS, listModel) { private static final long serialVersionUID = 1L; @Override protected ListItem<D> newItem(int index, IModel<D> itemModel) { return new OddEvenListItem<D>(index, itemModel); } @Override protected void populateItem(ListItem<D> item) { item.setModel(DaoEntityModelFactory.make(item.getModelObject())); item.add(makeDetailRowPanel(ROW, item.getModel())); } }; webMarkupContainer.add(details); }
From source file:ch.bd.qv.quiz.panels.RadioQuestionPanel.java
License:Apache License
public RadioQuestionPanel(String inner, RadioQuestion bq) { super(inner, bq); this.radioQuestion = bq; RadioGroup<String> rg = new RadioGroup<>("radiogroup", input); rg.add(new ListView<String>("repeater", Lists.newArrayList(bq.getAnswerKeys())) { @Override/* w w w .j a v a 2s . co m*/ protected void populateItem(ListItem<String> item) { item.add(new Radio("radio", item.getModel())); item.add(new Label("radio_label", new ResourceModel(item.getModelObject()))); } }); rg.setRequired(true); add(rg); }
From source file:com.axway.ats.testexplorer.pages.testcase.attachments.AttachmentsPanel.java
License:Apache License
@SuppressWarnings({ "unchecked", "rawtypes" })
public AttachmentsPanel(String id, final String testcaseId, final PageParameters parameters) {
super(id);// w w w .j av a 2 s. c o m
form = new Form<Object>("form");
buttonPanel = new WebMarkupContainer("buttonPanel");
noButtonPanel = new WebMarkupContainer("noButtonPanel");
fileContentContainer = new TextArea<String>("textFile", new Model<String>(""));
imageContainer = new WebMarkupContainer("imageFile");
fileContentInfo = new Label("fileContentInfo", new Model<String>(""));
buttons = getAllAttachedFiles(testcaseId);
form.add(fileContentContainer);
form.add(imageContainer);
form.add(fileContentInfo);
form.add(buttonPanel);
add(noButtonPanel);
add(form);
buttonPanel.setVisible(!(buttons == null));
fileContentContainer.setVisible(false);
imageContainer.setVisible(false);
fileContentInfo.setVisible(false);
noButtonPanel.setVisible(buttons == null);
// if noButtonPanel is visible, do not show form and vice versa
form.setVisible(!noButtonPanel.isVisible());
noButtonPanel.add(new Label("description", noButtonPanelInfo));
final ListView lv = new ListView("buttons", buttons) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem item) {
if (item.getIndex() % 2 != 0) {
item.add(AttributeModifier.replace("class", "oddRow"));
}
final String viewedFile = buttons.get(item.getIndex());
final String name = getFileSimpleName(buttons.get(item.getIndex()));
final Label buttonLabel = new Label("name", name);
Label fileSize = new Label("fileSize", getFileSize(viewedFile));
downloadFile = new DownloadLink("download", new File(" "), "");
downloadFile.setModelObject(new File(viewedFile));
downloadFile.setVisible(true);
alink = new AjaxLink("alink", item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
fileContentInfo.setVisible(true);
String fileContent = new String();
if (!isImage(viewedFile)) {
fileContentContainer.setVisible(true);
imageContainer.setVisible(false);
fileContent = getFileContent(viewedFile, name);
fileContentContainer.setModelObject(fileContent);
} else {
PageNavigation navigation = null;
try {
navigation = ((TestExplorerSession) Session.get()).getDbReadConnection()
.getNavigationForTestcase(testcaseId, getTESession().getTimeOffset());
} catch (DatabaseAccessException e) {
LOG.error("Can't get runId, suiteId and dbname for testcase with id=" + testcaseId,
e);
}
String runId = navigation.getRunId();
String suiteId = navigation.getSuiteId();
String dbname = TestExplorerUtils.extractPageParameter(parameters, "dbname");
fileContentInfo.setDefaultModelObject("Previewing '" + name + "' image");
final String url = "AttachmentsServlet?&runId=" + runId + "&suiteId=" + suiteId
+ "&testcaseId=" + testcaseId + "&dbname=" + dbname + "&fileName=" + name;
imageContainer.add(new AttributeModifier("src", new Model<String>(url)));
imageContainer.setVisible(true);
fileContentContainer.setVisible(false);
}
// first setting all buttons with the same state
String reverseButtonsState = "var cusid_ele = document.getElementsByClassName('attachedButtons'); "
+ "for (var i = 0; i < cusid_ele.length; ++i) { " + "var item = cusid_ele[i]; "
+ "item.style.color= \"#000000\";" + "}";
// setting CSS style to the pressed button and its label
String pressClickedButton = "var span = document.evaluate(\"//a[@class='button attachedButtons']/span[text()='"
+ name + "']\", "
+ "document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;"
+ "span.style.backgroundPosition=\"left bottom\";"
+ "span.style.padding=\"6px 0 4px 18px\";"
+ "var button = document.evaluate(\"//a[@class='button attachedButtons']/span[text()='"
+ name + "']/..\", "
+ "document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;"
+ "button.style.backgroundPosition=\"right bottom\";"
+ "button.style.color=\"#000000\";" + "button.style.outline=\"medium none\";";
// I could not figure out how it works with wicket, so i did it with JS
target.appendJavaScript(reverseButtonsState);
target.appendJavaScript(pressClickedButton);
target.add(form);
}
};
alink.add(buttonLabel);
item.add(alink);
item.add(downloadFile);
item.add(fileSize);
}
};
buttonPanel.add(lv);
}
From source file:com.cubeia.games.poker.admin.wicket.pages.system.VerifySystemAccounts.java
License:Open Source License
private void initPage() { AccountLookup accountLookup = new AccountLookup(walletService); List<AccountInformation> systemAccountList = new ArrayList<>(); List<AccountInformation> operatorAccountList = new ArrayList<>(); CurrencyListResult supportedCurrencies = walletService.getSupportedCurrencies(); List<AccountRole> systemRoles = new ArrayList<>(); systemRoles.add(AccountRole.MAIN);//from w w w .j av a 2s . c o m systemRoles.add(AccountRole.PROMOTION); systemRoles.add(AccountRole.RAKE); systemRoles.add(AccountRole.BONUS); List<AccountRole> operatorRoles = new ArrayList<>(); operatorRoles.add(AccountRole.MAIN); operatorRoles.add(AccountRole.RAKE); operatorRoles.add(AccountRole.BONUS); // Lookup system accounts AccountType type = AccountType.SYSTEM_ACCOUNT; boolean errorAlert = false; for (Currency currency : supportedCurrencies.getCurrencies()) { for (AccountRole role : systemRoles) { AccountInformation info = new AccountInformation(); info.setCurrency(currency.getCode()); info.setType(type); info.setRole(role); try { long accountId = accountLookup.lookupSystemAccount(currency.getCode(), role); if (accountId > 0) { info.setId(accountId); info.setFound(true); } } catch (NoSuchAccountException e) { info.setFound(false); errorAlert = true; } systemAccountList.add(info); } } final WebMarkupContainer alert = new WebMarkupContainer("errorAlert"); alert.setVisibilityAllowed(errorAlert); add(alert); // Lookup operator accounts List<OperatorDTO> operators = operatorService.getOperators(); type = AccountType.OPERATOR_ACCOUNT; for (OperatorDTO operator : operators) { for (Currency currency : supportedCurrencies.getCurrencies()) { for (AccountRole role : operatorRoles) { AccountInformation info = new AccountInformation(); info.setCurrency(currency.getCode()); info.setType(type); info.setRole(role); info.setOperator(operator.getId() + ":" + operator.getName()); try { long accountId = accountLookup.lookupOperatorAccount(operator.getId(), currency.getCode(), role); if (accountId > 0) { info.setId(accountId); info.setFound(true); } } catch (NoSuchAccountException e) { info.setFound(false); } operatorAccountList.add(info); } } } ListView<AccountInformation> systemList = new ListView<AccountInformation>("systemList", systemAccountList) { protected void populateItem(ListItem<AccountInformation> item) { AccountInformation info = item.getModel().getObject(); item.add(new Label("role", info.getRole())); item.add(new Label("currency", info.getCurrency())); Label found = new Label("accountFound", info.isFound() ? "ID " + info.getId() : "Missing"); if (info.isFound()) { found.add(new AttributeModifier("class", "label label-success")); } else { found.add(new AttributeModifier("class", "label label-warning")); } item.add(found); } }; add(systemList); ListView<AccountInformation> operatorList = new ListView<AccountInformation>("operatorList", operatorAccountList) { protected void populateItem(ListItem<AccountInformation> item) { AccountInformation info = item.getModel().getObject(); item.add(new Label("operator", info.getOperator())); item.add(new Label("role", info.getRole())); item.add(new Label("currency", info.getCurrency())); Label found = new Label("accountFound", info.isFound() ? "ID " + info.getId() : "Missing"); if (info.isFound()) { found.add(new AttributeModifier("class", "label label-success")); } else { found.add(new AttributeModifier("class", "label label-warning")); } item.add(found); } }; add(operatorList); }
From source file:com.doculibre.constellio.wicket.panels.admin.searchInterface.generalOptions.advancedSearch.AdvancedSearchOptionsListPanel.java
License:Open Source License
public AdvancedSearchOptionsListPanel(String id) { super(id);/* w ww.j a va2 s . c o m*/ IModel collectionsModel = new LoadableDetachableModel() { @Override protected Object load() { return ConstellioSpringUtils.getRecordCollectionServices().list(); } }; ListView collections = new ListView("collections", collectionsModel) { @Override protected void populateItem(final ListItem item) { RecordCollection collection = (RecordCollection) item.getModelObject(); Locale displayLocale = collection.getDisplayLocale(getLocale()); String collectionTitle = collection.getTitle(displayLocale); FoldableSectionPanel section = new FoldableSectionPanel("foldableSection", new Model(collectionTitle)) { @Override protected Component newFoldableSection(String id) { return new AdvancedSearchOptionsPanel(id, item.getModel()); } }; section.setOpened(false); item.add(section); } }; add(collections); }
From source file:com.evolveum.midpoint.gui.api.component.button.DropdownButtonPanel.java
License:Apache License
private void initMenuItem(ListItem<InlineMenuItem> menuItem) { final InlineMenuItem item = menuItem.getModelObject(); WebMarkupContainer menuItemBody = new MenuLinkPanel(ID_MENU_ITEM_BODY, menuItem.getModel()); menuItemBody.setRenderBodyOnly(true); menuItem.add(menuItemBody);/* w w w .j av a 2s . com*/ }
From source file:com.evolveum.midpoint.gui.api.component.PendingOperationPanel.java
License:Apache License
private void initLayout() { ListView<PendingOperationType> operation = new ListView<PendingOperationType>(ID_OPERATION, getModel()) { private static final long serialVersionUID = 1L; @Override/*www.j a v a2 s .c o m*/ protected void populateItem(ListItem<PendingOperationType> item) { item.setRenderBodyOnly(true); WebMarkupContainer label = new WebMarkupContainer(ID_LABEL); item.add(label); Label text = new Label(ID_TEXT, createLabelText(item.getModel())); text.setRenderBodyOnly(true); label.add(text); label.add(AttributeAppender.append("class", createTextClass(item.getModel()))); label.add(AttributeModifier.replace("title", createTextTooltipModel(item.getModel()))); label.add(new InfoTooltipBehavior() { @Override public String getCssClass() { return null; } }); } }; add(operation); }