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;
}
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;
}
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));
}
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) {
}
});
}
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);
}
Aggregations