Search in sources :

Example 36 with AjaxFormComponentUpdatingBehavior

use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project syncope by apache.

the class HistoryConfDetails method initDropdownDiffConfForm.

private Form<?> initDropdownDiffConfForm() {
    final Form<T> form = new Form<>("form");
    form.setModel(new CompoundPropertyModel<>(selectedHistoryConfTO));
    form.setOutputMarkupId(true);
    final Map<String, String> namesMap = getDropdownNamesMap(availableHistoryConfTOs);
    List<String> keys = new ArrayList<>(namesMap.keySet());
    final AjaxDropDownChoicePanel<String> dropdownElem = new AjaxDropDownChoicePanel<>("compareDropdown", getString("compare"), new PropertyModel<>(selectedHistoryConfTO, "key"), false);
    dropdownElem.setChoices(keys);
    dropdownElem.setChoiceRenderer(new IChoiceRenderer<String>() {

        private static final long serialVersionUID = -6265603675261014912L;

        @Override
        public Object getDisplayValue(final String value) {
            return namesMap.get(value) == null ? value : namesMap.get(value);
        }

        @Override
        public String getIdValue(final String value, final int i) {
            return value;
        }

        @Override
        public String getObject(final String id, final IModel<? extends List<? extends String>> choices) {
            return id;
        }
    });
    dropdownElem.setNullValid(true);
    dropdownElem.getField().add(new AjaxFormComponentUpdatingBehavior("onchange") {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            List<T> elemsToCompare = new ArrayList<>();
            elemsToCompare.add(selectedHistoryConfTO);
            final String selectedKey = dropdownElem.getModelObject();
            if (selectedKey != null) {
                if (!selectedKey.isEmpty()) {
                    T confToCompare = availableHistoryConfTOs.stream().filter(object -> object.getKey().equals(selectedKey)).findAny().orElse(null);
                    elemsToCompare.add(confToCompare);
                    showConfigurationDiffPanel(elemsToCompare);
                } else {
                    showConfigurationSinglePanel();
                }
            }
            target.add(jsonPanel);
        }
    });
    form.add(dropdownElem);
    return form;
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) Form(org.apache.wicket.markup.html.form.Form) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) SyncopeConsoleSession(org.apache.syncope.client.console.SyncopeConsoleSession) ResourceHistoryConfTO(org.apache.syncope.common.lib.to.ResourceHistoryConfTO) JsonDiffPanel(org.apache.syncope.client.console.wicket.markup.html.form.JsonDiffPanel) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) ResourceRestClient(org.apache.syncope.client.console.rest.ResourceRestClient) JsonEditorPanel(org.apache.syncope.client.console.wicket.markup.html.form.JsonEditorPanel) IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) BaseModal(org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AbstractHistoryConf(org.apache.syncope.common.lib.to.AbstractHistoryConf) IOException(java.io.IOException) PageReference(org.apache.wicket.PageReference) Collectors(java.util.stream.Collectors) List(java.util.List) ConnInstanceHistoryConfTO(org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO) PropertyModel(org.apache.wicket.model.PropertyModel) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ConnectorRestClient(org.apache.syncope.client.console.rest.ConnectorRestClient) Form(org.apache.wicket.markup.html.form.Form) ArrayList(java.util.ArrayList) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) List(java.util.List)

Example 37 with AjaxFormComponentUpdatingBehavior

use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project oc-explorer by devgateway.

the class CheckBoxPickerBootstrapFormComponent method inputField.

@Override
protected BootstrapCheckBoxPicker inputField(final String id, final IModel<Boolean> model) {
    config = new BootstrapCheckBoxPickerConfig().withOnClass("btn-info").withOffClass("btn-warning").withOnIcon(FontAwesomeIconType.thumbs_up).withOffIcon(FontAwesomeIconType.thumbs_down).withReverse(true).withStyle(ButtonGroup.Size.Small);
    final BootstrapCheckBoxPicker checkBoxPicker = new BootstrapCheckBoxPicker("field", initFieldModel(), config);
    checkBoxPicker.add(new AjaxFormComponentUpdatingBehavior("change") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            CheckBoxPickerBootstrapFormComponent.this.onUpdate(target);
        }
    });
    return checkBoxPicker;
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) BootstrapCheckBoxPickerConfig(de.agilecoders.wicket.extensions.markup.html.bootstrap.form.checkbox.bootstrapcheckbox.BootstrapCheckBoxPickerConfig) BootstrapCheckBoxPicker(de.agilecoders.wicket.extensions.markup.html.bootstrap.form.checkbox.bootstrapcheckbox.BootstrapCheckBoxPicker)

Example 38 with AjaxFormComponentUpdatingBehavior

use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project openmeetings by apache.

the class ConfigForm method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    add(new DropDownChoice<>("type", Arrays.asList(Type.values()), new IChoiceRenderer<Type>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getIdValue(Type rt, int index) {
            return rt.name();
        }

        @Override
        public Object getDisplayValue(Type rt) {
            return rt.name();
        }

        @Override
        public Type getObject(String id, IModel<? extends List<? extends Type>> choices) {
            for (Type rt : choices.getObject()) {
                if (rt.name().equals(id)) {
                    return rt;
                }
            }
            return null;
        }
    }).setLabel(Model.of(getString("45"))).add(new AjaxFormComponentUpdatingBehavior("change") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            update(target);
        }
    }));
    add(new RequiredTextField<String>("key").setLabel(Model.of(getString("265"))).add(new IValidator<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public void validate(IValidatable<String> validatable) {
            Configuration c = cfgDao.forceGet(validatable.getValue());
            if (c != null && !c.isDeleted() && !c.getId().equals(ConfigForm.this.getModelObject().getId())) {
                validatable.error(new ValidationError(getString("error.cfg.exist")));
            }
        }
    }));
    add(valueS.setLabel(Model.of(getString("271"))).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
    add(valueN.setLabel(Model.of(getString("271"))).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
    add(valueB.setLabel(Model.of(getString("271"))).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) IModel(org.apache.wicket.model.IModel) Configuration(org.apache.openmeetings.db.entity.basic.Configuration) IValidatable(org.apache.wicket.validation.IValidatable) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Type(org.apache.openmeetings.db.entity.basic.Configuration.Type) IValidator(org.apache.wicket.validation.IValidator) List(java.util.List) ValidationError(org.apache.wicket.validation.ValidationError)

Example 39 with AjaxFormComponentUpdatingBehavior

use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.

the class WebComponentUtil method addAjaxOnBlurUpdateBehaviorToComponent.

private static void addAjaxOnBlurUpdateBehaviorToComponent(final Component component) {
    component.setOutputMarkupId(true);
    component.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget)

Example 40 with AjaxFormComponentUpdatingBehavior

use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.

the class MultiValueChoosePanel method initLayout.

private void initLayout(final IModel<List<T>> chosenValues, final List<PrismReferenceValue> filterValues, final boolean required, final boolean multiselect) {
    AjaxLink<String> addButton = new AjaxLink<String>(ID_ADD_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            editValuePerformed(chosenValues.getObject(), filterValues, target, multiselect);
        }
    };
    addButton.setOutputMarkupPlaceholderTag(true);
    add(addButton);
    ListView<T> selectedRowsList = new ListView<T>(ID_SELECTED_ROWS, chosenValues) {

        @Override
        protected void populateItem(ListItem<T> item) {
            WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
            textWrapper.setOutputMarkupPlaceholderTag(true);
            // was value
            TextField<String> text = new TextField<>(ID_TEXT, createTextModel(item.getModel()));
            text.add(new AjaxFormComponentUpdatingBehavior("blur") {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
                }
            });
            text.setRequired(required);
            text.setEnabled(false);
            text.setOutputMarkupPlaceholderTag(true);
            textWrapper.add(text);
            FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text));
            feedback.setOutputMarkupPlaceholderTag(true);
            textWrapper.add(feedback);
            initButtons(item, item);
            item.add(textWrapper);
        }
    };
    selectedRowsList.setReuseItems(true);
    add(selectedRowsList);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Aggregations

AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)55 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)54 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)27 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)25 TextField (org.apache.wicket.markup.html.form.TextField)20 Label (org.apache.wicket.markup.html.basic.Label)18 List (java.util.List)17 IModel (org.apache.wicket.model.IModel)17 ArrayList (java.util.ArrayList)16 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)16 ListItem (org.apache.wicket.markup.html.list.ListItem)13 ListView (org.apache.wicket.markup.html.list.ListView)13 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)10 ComponentFeedbackMessageFilter (org.apache.wicket.feedback.ComponentFeedbackMessageFilter)9 CheckBox (org.apache.wicket.markup.html.form.CheckBox)8 Form (org.apache.wicket.markup.html.form.Form)8 FeedbackPanel (org.apache.wicket.markup.html.panel.FeedbackPanel)8 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)7 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)6 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)5