List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink setBody
public AbstractLink setBody(final IModel<?> bodyModel)
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.CacheListPanel.java
License:Apache License
private ListView<String> createServerListView(final Behavior updater, final ModalWindow modalWindow) { return new ListView<String>("servers", getServerList()) { private static final long serialVersionUID = 1L; @Override/*from w w w . j a v a 2s .co m*/ protected void populateItem(final ListItem<String> item) { final String cacheName = item.getModelObject(); item.add(new UpdatingAttributeAppender("class", new Model<String>("") { private static final long serialVersionUID = 1L; @Override public String getObject() { final CacheState cs = CacheState.getState(cacheName); if (cs != null && !cs.isAvailable()) { final String status = cs.getLastValue(HealthDeterminer.STATUS); if (status != null) { switch (HealthDeterminer.AdminStatus.valueOf(status)) { case ADMIN_DOWN: case OFFLINE: return "warning"; default: return "error"; } } else { return "error"; } } else { return " "; } } }, " ")); item.add(updater); Label label = new Label("status", new CacheStateModel(cacheName, "_status_string_")); label.add(updater); item.add(label); label = new Label("loadavg", new CacheStateModel(cacheName, "loadavg")); label.add(updater); item.add(label); label = new Label("queryTime", new CacheStateModel(cacheName, "queryTime")); label.add(updater); item.add(label); label = new Label("kbps", new CacheStateModel(cacheName, "kbps")); label.add(updater); item.add(label); label = new Label("maxKbps", new CacheStateModel(cacheName, "maxKbps")); label.add(updater); item.add(label); label = new Label("current_client_connections", new CacheStateModel(cacheName, "ats.proxy.process.http.current_client_connections")); label.add(updater); item.add(label); // final PageParameters pars = new PageParameters(); // pars.add("hostname", cacheName); // final BookmarkablePageLink<Object> link // = new BookmarkablePageLink<Object>("fulldetails", FullDetailsPage.class, pars); final AjaxLink<Void> link = new AjaxLink<Void>("fulldetails") { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { hostname = cacheName; modalWindow.show(target); } }; link.setBody(new Model<String>(cacheName)); item.add(link); } }; }
From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.DsListPanel.java
License:Apache License
private ListView<String> createDsListView(final Behavior updater, final ModalWindow modalWindow) { return new ListView<String>("ds", getDsList()) { private static final long serialVersionUID = 1L; @Override// www . j av a 2 s.c om protected void populateItem(final ListItem<String> item) { final String dsName = item.getModelObject(); item.add(new UpdatingAttributeAppender("class", new Model<String>("") { private static final long serialVersionUID = 1L; @Override public String getObject() { // if ( cacheState.isError() ) return "error"; final DsState cs = DsState.get(dsName); if (cs != null && !cs.isAvailable()) { return "error"; } // "grey" else { return " "; } } }, " ")); item.add(updater); Label label = new Label("status", new DsStateModel(dsName, "_status_string_")); label.add(updater); item.add(label); label = new Label("kbps", new DsStateModel(dsName, "total.kbps")); label.add(updater); item.add(label); label = new Label("tps", new DsStateModel(dsName, "total.tps_total")); label.add(updater); item.add(label); label = new Label("disabled", new DsStateModel(dsName, "disabledLocations")); label.add(updater); item.add(label); label = new Label("caches-reporting", new DsStateModel(dsName, "caches-reporting")); label.add(updater); item.add(label); label = new Label("caches-available", new DsStateModel(dsName, "caches-available")); label.add(updater); item.add(label); label = new Label("caches-configured", new DsStateModel(dsName, "caches-configured")); label.add(updater); item.add(label); final AjaxLink<Void> link = new AjaxLink<Void>("fulldetails") { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { dsId = dsName; modalWindow.show(target); } }; link.setBody(new Model<String>(dsName)); item.add(link); } }; }
From source file:com.evolveum.midpoint.gui.api.component.password.PasswordPanel.java
License:Apache License
private void initLayout(final IModel<ProtectedStringType> model, final boolean isReadOnly, boolean showRemoveButton) { setOutputMarkupId(true);//from w ww. j ava2s . com passwordInputVisble = model.getObject() == null; // TODO: remove // LOGGER.trace("PASSWORD model: {}", model.getObject()); final WebMarkupContainer inputContainer = new WebMarkupContainer(ID_INPUT_CONTAINER) { @Override public boolean isVisible() { return passwordInputVisble; } }; inputContainer.setOutputMarkupId(true); add(inputContainer); final PasswordTextField password1 = new PasswordTextField(ID_PASSWORD_ONE, new PasswordModel(model)); password1.setRequired(false); password1.setResetPassword(false); password1.setOutputMarkupId(true); password1.add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); inputContainer.add(password1); final PasswordTextField password2 = new PasswordTextField(ID_PASSWORD_TWO, new Model<String>()); password2.setRequired(false); password2.setResetPassword(false); password2.setOutputMarkupId(true); password2.add(new EmptyOnBlurAjaxFormUpdatingBehaviour()); inputContainer.add(password2); password1.add(new AjaxFormComponentUpdatingBehavior("change") { @Override protected void onUpdate(AjaxRequestTarget target) { boolean required = !StringUtils.isEmpty(password1.getModel().getObject()); password2.setRequired(required); //fix of MID-2463 // target.add(password2); // target.appendJavaScript("$(\"#"+ password2.getMarkupId() +"\").focus()"); } }); password2.add(new PasswordValidator(password1, password2)); final WebMarkupContainer linkContainer = new WebMarkupContainer(ID_LINK_CONTAINER) { @Override public boolean isVisible() { return !passwordInputVisble; } }; inputContainer.setOutputMarkupId(true); linkContainer.setOutputMarkupId(true); add(linkContainer); final Label passwordSetLabel = new Label(ID_PASSWORD_SET, new ResourceModel("passwordPanel.passwordSet")); linkContainer.add(passwordSetLabel); final Label passwordRemoveLabel = new Label(ID_PASSWORD_REMOVE, new ResourceModel("passwordPanel.passwordRemoveLabel")); passwordRemoveLabel.setVisible(false); linkContainer.add(passwordRemoveLabel); AjaxLink link = new AjaxLink(ID_CHANGE_PASSWORD_LINK) { @Override public void onClick(AjaxRequestTarget target) { onLinkClick(target); } @Override public boolean isVisible() { return !passwordInputVisble; } }; link.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return !isReadOnly; } }); link.setBody(new ResourceModel("passwordPanel.passwordChange")); link.setOutputMarkupId(true); linkContainer.add(link); final WebMarkupContainer removeButtonContainer = new WebMarkupContainer(ID_REMOVE_BUTTON_CONTAINER); AjaxLink removePassword = new AjaxLink(ID_REMOVE_PASSWORD_LINK) { @Override public void onClick(AjaxRequestTarget target) { onRemovePassword(model, target); } }; removePassword.setVisible(showRemoveButton); removePassword.setBody(new ResourceModel("passwordPanel.passwordRemove")); removePassword.setOutputMarkupId(true); removeButtonContainer.add(removePassword); add(removeButtonContainer); }
From source file:com.evolveum.midpoint.web.component.assignment.MultipleAssignmentSelectorPanel.java
License:Apache License
private void initLayout(Class<H> targetFocusClass, PageBase page) { IModel<List<AssignmentEditorDto>> availableAssignmentModel = createAvailableAssignmentModel(); final MultipleAssignmentSelector availableAssignmentsPanel = new MultipleAssignmentSelector<F, H>( ID_AVAILABLE_ASSIGNMENTS, availableAssignmentModel, targetFocusClass, type, focus, getFilterModel(true), page); final MultipleAssignmentSelector currentAssignmentsPanel = new MultipleAssignmentSelector<F, H>( ID_CURRENT_ASSIGNMENTS, assignmentsModel, targetFocusClass, type, null, getFilterModel(true), page) {//from w w w .j a va 2 s . c o m @Override protected List<AssignmentEditorDto> getListProviderDataList() { return assignmentsModel.getObject(); } }; currentAssignmentsPanel.setFilterButtonVisibility(false); AjaxButton add = new AjaxButton(ID_BUTTON_ADD) { @Override protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form form) { addToAssignmentsModel(target, availableAssignmentsPanel, currentAssignmentsPanel); } }; AjaxButton remove = new AjaxButton(ID_BUTTON_REMOVE) { @Override protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form form) { deleteFromAssignmentsModel(target, currentAssignmentsPanel, availableAssignmentsPanel); } }; remove.add(new VisibleEnableBehaviour() { @Override public boolean isEnabled() { return WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL); } }); AjaxLink<String> buttonReset = new AjaxLink<String>(ID_BUTTON_RESET) { @Override public void onClick(AjaxRequestTarget target) { reset(currentAssignmentsPanel); target.add(currentAssignmentsPanel); } }; buttonReset.setBody(createStringResource("MultipleAssignmentSelector.reset")); Form<?> form = new Form<Void>(ID_FORM); form.add(createTenantContainer()); form.add(createOrgContainer()); form.add(availableAssignmentsPanel); form.add(currentAssignmentsPanel); form.add(buttonReset); form.add(add); form.add(remove); add(form); }
From source file:com.evolveum.midpoint.web.component.assignment.SimpleRoleSelector.java
License:Apache License
private void initLayout() { setOutputMarkupId(true);//from w ww. ja v a 2 s . co m ListView<PrismObject<R>> list = new ListView<PrismObject<R>>(ID_LIST, availableRoles) { @Override protected void populateItem(ListItem<PrismObject<R>> item) { item.add(createRoleLink(ID_ITEM, item.getModel())); } }; list.setOutputMarkupId(true); add(list); AjaxLink<String> buttonReset = new AjaxLink<String>(ID_BUTTON_RESET) { @Override public void onClick(AjaxRequestTarget target) { reset(); target.add(SimpleRoleSelector.this); } }; buttonReset.setBody(createStringResource("SimpleRoleSelector.reset")); add(buttonReset); }
From source file:net.dontdrinkandroot.extensions.wicket.component.button.DropDownChoiceButton.java
License:Apache License
protected void populateItem(final ListItem<T> item) { final AjaxLink<Void> choiceLink = new AjaxLink<Void>("choiceLink") { @Override/*w w w . j a va 2s.co m*/ public void onClick(AjaxRequestTarget target) { DropDownChoiceButton.this.onSelectionChanged(target, item.getModelObject()); } }; choiceLink.setBody(new ChoiceModel(item.getModel())); item.add(choiceLink); }
From source file:net.dontdrinkandroot.wicket.bootstrap.component.button.ButtonGroupChoice.java
License:Apache License
public ButtonGroupChoice(String id, IModel<T> model, IModel<List<T>> choicesModel) { super(id, model); this.setOutputMarkupId(true); this.add(new CssClassAppender(BootstrapCssClass.BTN_GROUP)); final RepeatingView choicesView = new RepeatingView("choice"); choicesView.setOutputMarkupId(true); this.add(choicesView); for (final T choice : choicesModel.getObject()) { AjaxLink<Void> choiceLink = new AjaxLink<Void>(choicesView.newChildId()) { @Override// w ww. ja va 2 s . com public void onClick(AjaxRequestTarget target) { ButtonGroupChoice.this.onSelectionChanged(choice, target); } }; choiceLink.setBody(this.getDisplayModel(choice)); choiceLink.add(new CssClassAppender(new Model<BootstrapCssClass>() { @Override public BootstrapCssClass getObject() { if (ButtonGroupChoice.this.getModelObject().equals(choice)) { super.getObject(); } return null; } })); choicesView.add(choiceLink); } }
From source file:net.dontdrinkandroot.wicket.bootstrap.component.button.DropDownChoiceButton.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); this.setOutputMarkupId(true); this.add(new CssClassAppender(BootstrapCssClass.BTN_GROUP)); this.add(new CssClassAppender("dropdownchoice")); Label selectedLabel = new Label("selected", new ChoiceModel(this.getModel())); selectedLabel.add(new CssClassAppender("selection")); this.add(selectedLabel); ListView<T> choicesView = new ListView<T>("choiceItem", this.choicesModel) { @Override/*from w w w. ja v a 2 s . c o m*/ protected void populateItem(final ListItem<T> item) { AjaxLink<Void> choiceLink = new AjaxLink<Void>("choiceLink") { @Override public void onClick(AjaxRequestTarget target) { DropDownChoiceButton.this.onSelectionChanged(target, item.getModelObject()); } }; choiceLink.setBody(new ChoiceModel(item.getModel())); item.add(choiceLink); } }; this.add(choicesView); this.valueInputField = new HiddenField<T>("valueInput", this.getModel(), this.type); this.add(this.valueInputField); }
From source file:nl.mpi.lamus.web.components.UnlinkedNodesPanel.java
License:Open Source License
private List<IColumn<WorkspaceTreeNode, String>> createColumns() { List<IColumn<WorkspaceTreeNode, String>> columns = new ArrayList<>(); columns.add(new TreeColumn<WorkspaceTreeNode, String>( Model.of(getLocalizer().getString("unlinked_nodes_table_column_node", this)))); columns.add(new PropertyColumn<WorkspaceTreeNode, String>( Model.of(getLocalizer().getString("unlinked_nodes_table_column_type", this)), "type")); columns.add(new PropertyColumn<WorkspaceTreeNode, String>( Model.of(getLocalizer().getString("unlinked_nodes_table_column_status", this)), "statusAsString")); columns.add(new AbstractColumn<WorkspaceTreeNode, String>(Model.of("")) { @Override// w ww .j a va 2 s .c o m public void populateItem(Item<ICellPopulator<WorkspaceTreeNode>> cellItem, String componentId, IModel<WorkspaceTreeNode> model) { if (model.getObject().getParent() != null) { cellItem.add(new Label(componentId).setVisible(false)); return; } AjaxLink<WorkspaceTreeNode> deleteLink = new AutoDisablingAjaxLink<WorkspaceTreeNode>(componentId, model) { @Override public void onClick(AjaxRequestTarget target) { try { workspaceService.deleteNode(LamusSession.get().getUserId(), getModelObject()); target.add(UnlinkedNodesPanel.this); } catch (WorkspaceException | ProtectedNodeException ex) { error(ex.getMessage()); } } }; deleteLink.setBody(Model.of(getLocalizer().getString("unlinked_nodes_table_column_remove_button", UnlinkedNodesPanel.this))); deleteLink.add(AttributeModifier.append("class", new Model<>("tableActionLink"))); cellItem.add(deleteLink); } }); return columns; }
From source file:org.devgateway.eudevfin.projects.module.components.panels.ReportsTableListPanel.java
@Override protected void populateTable() { final ModalWindow modal = AddModalWindow(null); this.itemsListView = new ListView<ProjectReport>("projectReportsList", items) { private static final long serialVersionUID = -8758662617501215830L; @Override//from w w w . j a v a2 s .com protected void populateItem(ListItem<ProjectReport> listItem) { final ProjectReport report = listItem.getModelObject(); AjaxLink linkToEdit = new AjaxLink("linkToEditReport") { @Override public void onClick(AjaxRequestTarget target) { PageParameters parameters = new PageParameters().add(ReportsTableModal.PARAM_REPORT_ID, report.getId()); setParameters(parameters); AddModalWindow(parameters); modal.show(target); } }; Label reportTitleLabel = new Label("reportTitle", report.getReportTitle()); String reportTypeName = new StringResourceModel(report.getType(), ReportsTableListPanel.this, null) .getString(); linkToEdit.setBody(Model.of(reportTypeName)); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); LocalDate date = report.getFormattedReportDate() == null ? new LocalDate() : report.getFormattedReportDate(); Label reportDateLabel = new Label("reportDate", dateFormat.format(date.toDate())); LocalDate reportingPeriodStart = report.getFormattedReportingPeriodStart() == null ? new LocalDate() : report.getFormattedReportingPeriodStart(); Label reportingPeriodStartLabel = new Label("reportingPeriodStart", dateFormat.format(reportingPeriodStart.toDate())); LocalDate reportingPeriodEnd = report.getFormattedReportingPeriodEnd() == null ? new LocalDate() : report.getFormattedReportingPeriodEnd(); Label reportingPeriodEndLabel = new Label("reportingPeriodEnd", dateFormat.format(reportingPeriodEnd.toDate())); Label fileProvidedLabel = new Label("fileProvided", report.getFileProvided()); Label fileNameLabel = new Label("reportFile", report.getReportFiles().toString()); listItem.add(linkToEdit); listItem.add(reportTitleLabel); listItem.add(reportDateLabel); listItem.add(reportingPeriodStartLabel); listItem.add(reportingPeriodEndLabel); listItem.add(fileProvidedLabel); listItem.add(fileNameLabel); } }; itemsListView.setOutputMarkupId(true); this.add(modal); this.add(itemsListView); }