use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class PrismValuePanel method createInputComponent.
private Panel createInputComponent(String id, IModel<String> labelModel, Form form) {
ValueWrapper valueWrapper = valueWrapperModel.getObject();
ObjectWrapper objectWrapper = null;
if (valueWrapper.getItem().getContainer() != null) {
objectWrapper = valueWrapper.getItem().getContainer().getObject();
}
Item property = valueWrapper.getItem().getItem();
boolean required = property.getDefinition().getMinOccurs() > 0;
Panel component = createTypedInputComponent(id);
if (component instanceof InputPanel) {
InputPanel inputPanel = (InputPanel) component;
//adding valid from/to date range validator, if necessary
ItemPath activation = new ItemPath(UserType.F_ACTIVATION);
if (ActivationType.F_VALID_FROM.equals(property.getElementName())) {
DateValidator validator = WebComponentUtil.getRangeValidator(form, activation);
validator.setDateFrom((DateTimeField) inputPanel.getBaseFormComponent());
} else if (ActivationType.F_VALID_TO.equals(property.getElementName())) {
DateValidator validator = WebComponentUtil.getRangeValidator(form, activation);
validator.setDateTo((DateTimeField) inputPanel.getBaseFormComponent());
}
final List<FormComponent> formComponents = inputPanel.getFormComponents();
for (FormComponent formComponent : formComponents) {
formComponent.setLabel(labelModel);
formComponent.setRequired(required);
if (formComponent instanceof TextField) {
formComponent.add(new AttributeModifier("size", "42"));
}
formComponent.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
// Validation occurs when submitting the form
// if (form != null) {
// AjaxFormValidatingBehavior validator = new AjaxFormValidatingBehavior(form, "Blur");
//
// formComponent.add(validator);
// }
}
}
if (component == null) {
throw new RuntimeException("Cannot create input component for item " + property + " (" + valueWrapper + ") in " + objectWrapper);
}
return component;
}
use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class TextPopupPanel method initLayout.
private void initLayout() {
final TextField input = initTextField();
input.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
//nothing to do, just update model data
}
});
input.add(new Behavior() {
@Override
public void bind(Component component) {
super.bind(component);
component.add(AttributeModifier.replace("onkeydown", Model.of("if(event.keyCode == 13) {event.preventDefault();}")));
}
});
input.setOutputMarkupId(true);
add(input);
}
use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class ObjectPolicyPanel method initLayout.
// public void updateModel(AjaxRequestTarget target, ObjectPolicyConfigurationTypeDto config) {
// model.setObject(new ObjectPolicyDialogDto(config, getPageBase()));
// target.add(getContent());
// }
public void initLayout() {
Form form = new Form(ID_FORM);
form.setOutputMarkupId(true);
add(form);
DropDownFormGroup type = new DropDownFormGroup<>(ID_TYPE, new PropertyModel<QName>(model, ObjectPolicyDialogDto.F_TYPE), createTypeChoiceList(), new QNameChoiceRenderer(), createStringResource("ObjectPolicyDialog.type"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
form.add(type);
type.getInput().setNullValid(false);
type.getInput().setRequired(true);
TextField<String> fieldSubtype = new TextField<>(ID_SUBTYPE, new PropertyModel<String>(model, ObjectPolicyDialogDto.F_SUBTYPE));
form.add(fieldSubtype);
form.add(fieldSubtype);
DropDownFormGroup template = new DropDownFormGroup<>(ID_OBJECT_TEMPLATE, new PropertyModel<ObjectTemplateConfigTypeReferenceDto>(model, ObjectPolicyDialogDto.F_TEMPLATE_REF), createObjectTemplateList(), new ChoiceableChoiceRenderer<ObjectTemplateConfigTypeReferenceDto>(), createStringResource("ObjectPolicyDialog.template"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
form.add(template);
template.getInput().setNullValid(false);
template.getInput().setRequired(true);
ListView repeater = new ListView<PropertyConstraintTypeDto>(ID_REPEATER, new PropertyModel<List<PropertyConstraintTypeDto>>(model, ObjectPolicyDialogDto.F_PROPERTY_LIST)) {
@Override
protected void populateItem(final ListItem item) {
WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (item.getIndex() > 0) {
return OFFSET_CLASS + " " + CLASS_MULTI_VALUE;
}
return null;
}
}));
item.add(textWrapper);
TextField property = new TextField<>(ID_PROPERTY, new PropertyModel<String>(item.getModel(), PropertyConstraintTypeDto.F_PROPERTY_PATH));
property.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
property.add(AttributeAppender.replace("placeholder", createStringResource("ObjectPolicyDialog.property.placeholder")));
textWrapper.add(property);
CheckBox oidBound = new CheckBox(ID_OID_BOUND, new PropertyModel<Boolean>(item.getModel(), PropertyConstraintTypeDto.F_OID_BOUND));
oidBound.add(AttributeModifier.replace("title", createStringResource("ObjectPolicyDialog.label.oidBound.help")));
textWrapper.add(oidBound);
WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (item.getIndex() > 0) {
return CLASS_MULTI_VALUE;
}
return null;
}
}));
item.add(buttonGroup);
initButtons(buttonGroup, item);
}
};
form.add(repeater);
AjaxSubmitButton cancel = new AjaxSubmitButton(ID_BUTTON_CANCEL, createStringResource("ObjectPolicyDialog.button.cancel")) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
cancelPerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
cancelPerformed(target);
}
};
form.add(cancel);
AjaxSubmitButton save = new AjaxSubmitButton(ID_BUTTON_SAVE, createStringResource("ObjectPolicyDialog.button.save")) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
savePerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(form);
}
};
form.add(save);
}
use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class SimpleParametricRoleSelector method initLayout.
private void initLayout() {
IModel<String> labelParamModel = new IModel<String>() {
@Override
public void detach() {
}
@Override
public String getObject() {
return getLabelParam();
}
@Override
public void setObject(String object) {
}
};
add(new Label(ID_LABEL_PARAM, labelParamModel) {
@Override
protected void onConfigure() {
setVisible(getLabelParam() != null);
super.onConfigure();
}
});
IModel<String> labelRoleModel = new IModel<String>() {
@Override
public void detach() {
}
@Override
public String getObject() {
return getLabelRole();
}
@Override
public void setObject(String object) {
}
};
add(new Label(ID_LABEL_ROLE, labelRoleModel) {
@Override
protected void onConfigure() {
setVisible(getLabelRole() != null);
super.onConfigure();
}
});
paramList = new ListView<String>(ID_LIST_PARAM, paramListModel) {
@Override
protected void populateItem(ListItem<String> item) {
item.add(createParamLink(ID_ITEM_PARAM, item.getModel()));
}
};
paramList.setOutputMarkupId(true);
add(paramList);
final Model<String> addInputModel = new Model<String>();
TextField<String> addInput = new TextField<>(ID_ADD_INPUT, addInputModel);
addInput.setOutputMarkupId(true);
addInput.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
// nothing to do, Ajax behavior is there only to get data to model
}
});
add(addInput);
AjaxLink<String> addLink = new AjaxLink<String>(ID_ADD_LINK) {
@Override
public void onClick(AjaxRequestTarget target) {
String newParam = addInputModel.getObject();
LOGGER.debug("ADD cliked, input field value: {}", newParam);
if (!StringUtils.isBlank(newParam)) {
addParam(newParam);
}
addInputModel.setObject(null);
target.add(SimpleParametricRoleSelector.this);
}
};
add(addLink);
AjaxLink<String> deleteLink = new AjaxLink<String>(ID_DELETE_LINK) {
@Override
public void onClick(AjaxRequestTarget target) {
LOGGER.debug("DELETE cliked, selected param: {}", selectedParam);
deleteParam(selectedParam);
target.add(SimpleParametricRoleSelector.this);
}
};
add(deleteLink);
}
use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class ACAttributeValuePanel method initLayout.
private void initLayout(Form form, boolean ignoreMandatoryAttributes) {
ACValueConstructionDto dto = getModel().getObject();
PrismPropertyDefinition definition = dto.getAttribute().getDefinition();
InputPanel input = createTypedInputComponent(ID_INPUT, definition);
for (FormComponent comp : input.getFormComponents()) {
comp.setLabel(new PropertyModel(dto.getAttribute(), ACAttributeDto.F_NAME));
if (!ignoreMandatoryAttributes) {
comp.setRequired(definition.getMinOccurs() > 0);
}
comp.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
}
add(input);
AjaxLink addLink = new AjaxLink(ID_ADD) {
@Override
public void onClick(AjaxRequestTarget target) {
addPerformed(target);
}
};
add(addLink);
addLink.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isAddVisible();
}
});
AjaxLink removeLink = new AjaxLink(ID_REMOVE) {
@Override
public void onClick(AjaxRequestTarget target) {
removePerformed(target);
}
};
add(removeLink);
removeLink.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isRemoveVisible();
}
});
}
Aggregations