use of org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink in project midpoint by Evolveum.
the class MultiValueTextEditPanel method initButtons.
private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item, NonEmptyModel<Boolean> readOnlyModel) {
AjaxSubmitLink edit = new AjaxSubmitLink(ID_EDIT) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
editPerformed(target, item.getModelObject());
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(getPageBase().getFeedbackPanel());
}
};
edit.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (buttonsDisabled()) {
return " " + CSS_DISABLED;
}
return "";
}
}));
buttonGroup.add(edit);
AjaxLink add = new AjaxLink(ID_ADD) {
@Override
public void onClick(AjaxRequestTarget target) {
addValuePerformed(target);
}
};
add.add(new AttributeAppender("class", getPlusClassModifier(item)));
add.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(add);
AjaxLink remove = new AjaxLink(ID_REMOVE) {
@Override
public void onClick(AjaxRequestTarget target) {
removeValuePerformed(target, item);
}
};
remove.add(new AttributeAppender("class", getMinusClassModifier()));
remove.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
buttonGroup.add(remove);
}
use of org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink in project midpoint by Evolveum.
the class MenuLinkPanel method initLayout.
private void initLayout(IModel<InlineMenuItem> item) {
InlineMenuItem dto = item.getObject();
AbstractLink a;
if (dto.isSubmit()) {
a = new AjaxSubmitLink(ID_MENU_ITEM_LINK) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
MenuLinkPanel.this.onSubmit(target, form, dto.getAction(), item);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
MenuLinkPanel.this.onError(target, form, dto.getAction());
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
}
};
} else {
a = new AjaxLink(ID_MENU_ITEM_LINK) {
@Override
public void onClick(AjaxRequestTarget target) {
MenuLinkPanel.this.onClick(target, dto.getAction(), item);
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
}
};
}
add(a);
a.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (dto.getAction() == null) {
return false;
}
return true;
}
});
Label span = new Label(ID_MENU_ITEM_LABEL, dto.getLabel());
span.setRenderBodyOnly(true);
a.add(span);
}
use of org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink in project midpoint by Evolveum.
the class PageAccounts method initLinks.
private void initLinks(Form form, Form accForm) {
AjaxSubmitLink listSyncDetails = new AjaxSubmitLink(ID_LIST_SYNC_DETAILS) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
listSyncDetailsPerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(getFeedbackPanel());
}
};
form.add(listSyncDetails);
AjaxSubmitLink export = new AjaxSubmitLink(ID_EXPORT) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
exportPerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(getFeedbackPanel());
}
};
form.add(export);
AjaxLink clearExport = new AjaxLink(ID_CLEAR_EXPORT) {
@Override
public void onClick(AjaxRequestTarget target) {
clearExportPerformed(target);
}
};
accForm.add(clearExport);
}
use of org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink in project midpoint by Evolveum.
the class NotificationConfigPanel method initLayout.
@Override
protected void initLayout() {
TextField<String> defaultFromField = WebComponentUtil.createAjaxTextField(ID_DEFAULT_FROM, new PropertyModel<String>(getModel(), "defaultFrom"));
CheckBox debugCheck = WebComponentUtil.createAjaxCheckBox(ID_DEBUG, new PropertyModel<Boolean>(getModel(), "debug"));
DropDownChoice mailServerConfigChooser = new DropDownChoice<>(ID_MAIL_SERVER, new PropertyModel<MailServerConfigurationTypeDto>(getModel(), NotificationConfigurationDto.F_SELECTED_SERVER), new AbstractReadOnlyModel<List<MailServerConfigurationTypeDto>>() {
@Override
public List<MailServerConfigurationTypeDto> getObject() {
return getModel().getObject().getServers();
}
}, new ChoiceableChoiceRenderer<MailServerConfigurationTypeDto>());
mailServerConfigChooser.setNullValid(true);
mailServerConfigChooser.add(new AjaxFormSubmitBehavior("click") {
@Override
protected void onEvent(AjaxRequestTarget target) {
getForm().onFormSubmitted();
}
});
mailServerConfigChooser.add(new OnChangeAjaxBehavior() {
@Override
protected void onUpdate(AjaxRequestTarget target) {
preparePasswordFieldPlaceholder();
target.add(NotificationConfigPanel.this);
}
});
add(mailServerConfigChooser);
Label serverConfigTooltip = new Label(ID_MAIL_SERVER_TOOLTIP);
serverConfigTooltip.add(new InfoTooltipBehavior());
add(serverConfigTooltip);
WebMarkupContainer serverConfigContainer = new WebMarkupContainer(ID_MAIL_SERVER_CONFIG_CONTAINER);
serverConfigContainer.setOutputMarkupId(true);
serverConfigContainer.setOutputMarkupPlaceholderTag(true);
serverConfigContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (getModelObject() != null) {
return getModelObject().getSelectedServer() != null;
}
return false;
}
});
add(serverConfigContainer);
TextField<String> hostField = WebComponentUtil.createAjaxTextField(ID_HOST, new PropertyModel<String>(getModel(), "selectedServer.host"));
TextField<Integer> portField = WebComponentUtil.createAjaxTextField(ID_PORT, new PropertyModel<Integer>(getModel(), "selectedServer.port"));
TextField<String> userNameField = WebComponentUtil.createAjaxTextField(ID_USERNAME, new PropertyModel<String>(getModel(), "selectedServer.username"));
PasswordTextField passwordField = new PasswordTextField(ID_PASSWORD, new PropertyModel<String>(getModel(), "selectedServer.password"));
passwordField.setRequired(false);
passwordField.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
TextField<String> redirectToFileField = WebComponentUtil.createAjaxTextField(ID_REDIRECT_TO_FILE, new PropertyModel<String>(getModel(), "redirectToFile"));
DropDownFormGroup transportSecurity = new DropDownFormGroup<>(ID_TRANSPORT_SECURITY, new PropertyModel<MailTransportSecurityType>(getModel(), "selectedServer.mailTransportSecurityType"), WebComponentUtil.createReadonlyModelFromEnum(MailTransportSecurityType.class), new EnumChoiceRenderer<MailTransportSecurityType>(this), createStringResource("SystemConfigPanel.mail.transportSecurity"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
// transportSecurity.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
serverConfigContainer.add(hostField);
serverConfigContainer.add(portField);
serverConfigContainer.add(userNameField);
serverConfigContainer.add(passwordField);
serverConfigContainer.add(transportSecurity);
add(defaultFromField);
add(debugCheck);
add(redirectToFileField);
AjaxSubmitLink buttonAddNewMailServerConfig = new AjaxSubmitLink(ID_BUTTON_ADD_NEW_MAIL_SERVER_CONFIG) {
@Override
protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
MailServerConfigurationTypeDto newConfig = new MailServerConfigurationTypeDto();
newConfig.setHost(getString("SystemConfigPanel.mail.config.placeholder"));
if (getModelObject() != null) {
getModelObject().getServers().add(newConfig);
getModelObject().setSelectedServer(newConfig);
}
preparePasswordFieldPlaceholder();
target.add(NotificationConfigPanel.this, getPageBase().getFeedbackPanel());
}
@Override
protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
target.add(getPageBase().getFeedbackPanel());
}
};
add(buttonAddNewMailServerConfig);
AjaxSubmitLink removeMailServerConfig = new AjaxSubmitLink(ID_BUTTON_REMOVE_MAIL_SERVER_CONFIG) {
@Override
protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
if (getModelObject() != null) {
NotificationConfigurationDto notificationConfig = getModelObject();
MailServerConfigurationTypeDto selected = notificationConfig.getSelectedServer();
if (notificationConfig.getServers().contains(selected)) {
notificationConfig.getServers().remove(selected);
notificationConfig.setSelectedServer(null);
} else {
warn(getString("SystemConfigPanel.mail.server.remove.warn"));
}
target.add(NotificationConfigPanel.this, getPageBase().getFeedbackPanel());
}
}
@Override
protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
target.add(getPageBase().getFeedbackPanel());
}
};
removeMailServerConfig.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
if (getModelObject() != null && getModelObject().getSelectedServer() != null) {
return null;
} else {
return " disabled";
}
}
}));
add(removeMailServerConfig);
}
use of org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink in project midpoint by Evolveum.
the class ExpressionEditorPanel method initLayout.
protected void initLayout(PageResourceWizard parentPage) {
parentPage.addEditingEnabledBehavior(this);
setOutputMarkupId(true);
loadDtoModel();
Label descriptionLabel = new Label(ID_LABEL_DESCRIPTION, createStringResource(getDescriptionLabelKey()));
add(descriptionLabel);
TextArea description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(dtoModel, ExpressionTypeDto.F_DESCRIPTION));
description.setOutputMarkupId(true);
//parentPage.addEditingEnabledBehavior(description);
add(description);
Label typeLabel = new Label(ID_LABEL_TYPE, createStringResource(getTypeLabelKey()));
add(typeLabel);
DropDownChoice type = new DropDownChoice<>(ID_TYPE, new PropertyModel<ExpressionUtil.ExpressionEvaluatorType>(dtoModel, ExpressionTypeDto.F_TYPE), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.ExpressionEvaluatorType.class), new EnumChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType>(this));
//parentPage.addEditingEnabledBehavior(type);
type.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
dtoModel.getObject().updateExpressionType();
//target.add(get(ID_LANGUAGE_CONTAINER), get(ID_POLICY_CONTAINER), get(ID_EXPRESSION));
// because of ACE editor
target.add(ExpressionEditorPanel.this);
}
});
type.setOutputMarkupId(true);
type.setOutputMarkupPlaceholderTag(true);
type.setNullValid(true);
add(type);
WebMarkupContainer languageContainer = new WebMarkupContainer(ID_LANGUAGE_CONTAINER);
languageContainer.setOutputMarkupId(true);
languageContainer.setOutputMarkupPlaceholderTag(true);
languageContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return ExpressionUtil.ExpressionEvaluatorType.SCRIPT.equals(dtoModel.getObject().getType());
}
});
//parentPage.addEditingEnabledBehavior(languageContainer);
add(languageContainer);
DropDownChoice language = new DropDownChoice<>(ID_LANGUAGE, new PropertyModel<ExpressionUtil.Language>(dtoModel, ExpressionTypeDto.F_LANGUAGE), WebComponentUtil.createReadonlyModelFromEnum(ExpressionUtil.Language.class), new EnumChoiceRenderer<ExpressionUtil.Language>(this));
//parentPage.addEditingEnabledBehavior(language);
language.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
dtoModel.getObject().updateExpressionLanguage();
//target.add(get(ID_LANGUAGE_CONTAINER), get(ID_POLICY_CONTAINER), get(ID_EXPRESSION));
// because of ACE editor
target.add(ExpressionEditorPanel.this);
}
});
language.setNullValid(false);
languageContainer.add(language);
WebMarkupContainer policyContainer = new WebMarkupContainer(ID_POLICY_CONTAINER);
policyContainer.setOutputMarkupId(true);
policyContainer.setOutputMarkupPlaceholderTag(true);
policyContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return ExpressionUtil.ExpressionEvaluatorType.GENERATE.equals(dtoModel.getObject().getType());
}
});
add(policyContainer);
DropDownChoice policyRef = new DropDownChoice<>(ID_POLICY_REF, new PropertyModel<ObjectReferenceType>(dtoModel, ExpressionTypeDto.F_POLICY_REF), new AbstractReadOnlyModel<List<ObjectReferenceType>>() {
@Override
public List<ObjectReferenceType> getObject() {
return WebModelServiceUtils.createObjectReferenceList(ValuePolicyType.class, getPageBase(), policyMap);
}
}, new ObjectReferenceChoiceRenderer(policyMap));
//parentPage.addEditingEnabledBehavior(policyRef);
policyRef.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
dtoModel.getObject().updateExpressionValuePolicyRef();
target.add(get(ID_LANGUAGE_CONTAINER), get(ID_POLICY_CONTAINER), get(ID_EXPRESSION));
}
});
policyRef.setNullValid(true);
policyContainer.add(policyRef);
Label expressionLabel = new Label(ID_LABEL_EXPRESSION, createStringResource(getExpressionLabelKey()));
add(expressionLabel);
AceEditor expression = new AceEditor(ID_EXPRESSION, new PropertyModel<String>(dtoModel, ExpressionTypeDto.F_EXPRESSION));
expression.setOutputMarkupId(true);
//parentPage.addEditingEnabledBehavior(expression);
add(expression);
AjaxSubmitLink update = new AjaxSubmitLink(ID_BUTTON_UPDATE) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
updateExpressionPerformed(target);
}
};
Label updateLabel = new Label(ID_LABEL_UPDATE, createStringResource(getUpdateLabelKey()));
updateLabel.setRenderBodyOnly(true);
update.add(updateLabel);
parentPage.addEditingVisibleBehavior(update);
add(update);
add(WebComponentUtil.createHelp(ID_T_TYPE));
languageContainer.add(WebComponentUtil.createHelp(ID_T_LANGUAGE));
policyContainer.add(WebComponentUtil.createHelp(ID_T_POLICY));
add(WebComponentUtil.createHelp(ID_T_EXPRESSION));
}
Aggregations