use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class PasswordPanel method initLayout.
private void initLayout(final IModel<ProtectedStringType> model, final boolean isReadOnly) {
setOutputMarkupId(true);
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.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
PageBase pageBase = (PageBase) getPage();
if (pageBase == null) {
return false;
}
if (pageBase instanceof PageSelfProfile) {
return false;
}
if (pageBase instanceof PageUser && model.getObject() != null && !model.getObject().isEmpty()) {
return true;
}
return false;
}
});
removePassword.setBody(new ResourceModel("passwordPanel.passwordRemove"));
removePassword.setOutputMarkupId(true);
removeButtonContainer.add(removePassword);
add(removeButtonContainer);
}
use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class ValueChoosePanel method initLayout.
private void initLayout(final IModel<T> value, final List<PrismReferenceValue> values, final boolean required, Collection<Class<? extends O>> types) {
WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
textWrapper.setOutputMarkupId(true);
TextField<String> text = new TextField<String>(ID_TEXT, createTextModel(value));
text.add(new AjaxFormComponentUpdatingBehavior("blur") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
}
});
text.setRequired(required);
text.setEnabled(false);
textWrapper.add(text);
FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text));
textWrapper.add(feedback);
AjaxLink<String> edit = new AjaxLink<String>(ID_EDIT) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
editValuePerformed(values, target);
}
};
textWrapper.add(edit);
add(textWrapper);
initButtons();
}
use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class AssignmentEditorPanel method addAjaxOnBlurUpdateBehaviorToComponent.
private 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 PageDebugView method addOrReplaceEditor.
private void addOrReplaceEditor() {
editor = new AceEditor("aceEditor", new PropertyModel<String>(model, ObjectViewDto.F_XML));
editor.setModeForDataLanguage(dataLanguage);
editor.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
mainForm.addOrReplace(editor);
}
use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class ResourceRelatedHandlerPanel method initLayout.
private void initLayout() {
final VisibleEnableBehaviour visibleIfEdit = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return parentPage.isEdit();
}
};
final VisibleEnableBehaviour visibleIfView = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !parentPage.isEdit();
}
};
enabledIfEdit = new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit();
}
};
final VisibleEnableBehaviour visibleForResourceCoordinates = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getTaskDto().configuresResourceCoordinates();
}
};
final WebMarkupContainer resourceRefContainer = new WebMarkupContainer(ID_RESOURCE_REF_CONTAINER);
resourceRefContainer.add(visibleForResourceCoordinates);
resourceRefContainer.setOutputMarkupId(true);
add(resourceRefContainer);
final DropDownChoice<TaskAddResourcesDto> resourceRef = new DropDownChoice<>(ID_RESOURCE_REF, new PropertyModel<TaskAddResourcesDto>(getModel(), ResourceRelatedHandlerDto.F_RESOURCE_REFERENCE), new AbstractReadOnlyModel<List<TaskAddResourcesDto>>() {
@Override
public List<TaskAddResourcesDto> getObject() {
return createResourceList();
}
}, new ChoiceableChoiceRenderer<TaskAddResourcesDto>());
resourceRef.setOutputMarkupId(true);
resourceRef.add(enabledIfEdit);
resourceRef.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
Task task = parentPage.createSimpleTask(OPERATION_LOAD_RESOURCE);
OperationResult result = task.getResult();
List<QName> objectClassList = new ArrayList<>();
TaskAddResourcesDto resourcesDto = getModelObject().getResourceRef();
if (resourcesDto != null) {
PrismObject<ResourceType> resource = WebModelServiceUtils.loadObject(ResourceType.class, resourcesDto.getOid(), parentPage, task, result);
try {
ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resource, parentPage.getPrismContext());
schema.getObjectClassDefinitions();
for (Definition def : schema.getDefinitions()) {
objectClassList.add(def.getTypeName());
}
getModelObject().setObjectClassList(objectClassList);
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object class list from resource.", e);
error("Couldn't load object class list from resource.");
}
}
target.add(resourceRefContainer);
}
});
resourceRefContainer.add(resourceRef);
WebMarkupContainer kindContainer = new WebMarkupContainer(ID_KIND_CONTAINER);
kindContainer.add(visibleForResourceCoordinates);
add(kindContainer);
final DropDownChoice kind = new DropDownChoice<>(ID_KIND, new PropertyModel<ShadowKindType>(getModel(), ResourceRelatedHandlerDto.F_KIND), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>());
kind.setOutputMarkupId(true);
kind.setNullValid(true);
kindContainer.add(kind);
WebMarkupContainer intentContainer = new WebMarkupContainer(ID_INTENT_CONTAINER);
intentContainer.add(visibleForResourceCoordinates);
add(intentContainer);
final TextField<String> intent = new TextField<>(ID_INTENT, new PropertyModel<String>(getModel(), ResourceRelatedHandlerDto.F_INTENT));
intentContainer.add(intent);
intent.setOutputMarkupId(true);
intent.add(enabledIfEdit);
WebMarkupContainer objectClassContainer = new WebMarkupContainer(ID_OBJECT_CLASS_CONTAINER);
objectClassContainer.add(visibleForResourceCoordinates);
add(objectClassContainer);
AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
autoCompleteSettings.setShowListOnEmptyInput(true);
final AutoCompleteTextField<String> objectClass = new AutoCompleteTextField<String>(ID_OBJECT_CLASS, new PropertyModel<String>(getModel(), ResourceRelatedHandlerDto.F_OBJECT_CLASS), autoCompleteSettings) {
@Override
protected Iterator<String> getChoices(String input) {
return prepareObjectClassChoiceList(input);
}
};
objectClass.add(enabledIfEdit);
objectClassContainer.add(objectClass);
WebMarkupContainer optionsContainer = new WebMarkupContainer(ID_OPTIONS_CONTAINER);
optionsContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getTaskDto().configuresDryRun();
}
});
add(optionsContainer);
WebMarkupContainer dryRunContainer = new WebMarkupContainer(ID_DRY_RUN_CONTAINER);
dryRunContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getTaskDto().configuresDryRun();
}
});
optionsContainer.add(dryRunContainer);
CheckBox dryRun = new CheckBox(ID_DRY_RUN, new PropertyModel<Boolean>(getModel(), ResourceRelatedHandlerDto.F_DRY_RUN));
dryRun.add(enabledIfEdit);
dryRunContainer.add(dryRun);
}
Aggregations