use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class DirectlyEditablePropertyColumn method createInputPanel.
protected InputPanel createInputPanel(String componentId, final IModel<T> model) {
TextPanel<?> textPanel = new TextPanel<String>(componentId, new PropertyModel<>(model, getPropertyExpression()));
// UGLY HACK
TextField<?> textField = (TextField<?>) textPanel.getBaseFormComponent();
textField.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
onBlur(target, model);
}
});
return textPanel;
}
use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class SearchPanel method initPopover.
private void initPopover() {
WebMarkupContainer popover = new WebMarkupContainer(ID_POPOVER);
popover.setOutputMarkupId(true);
add(popover);
final WebMarkupContainer propList = new WebMarkupContainer(ID_PROP_LIST);
propList.setOutputMarkupId(true);
popover.add(propList);
ListView properties = new ListView<SearchItemDefinition>(ID_PROPERTIES, new PropertyModel<>(moreDialogModel, MoreDialogDto.F_PROPERTIES)) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<SearchItemDefinition> item) {
CheckBox check = new CheckBox(ID_CHECK, new PropertyModel<>(item.getModel(), SearchItemDefinition.F_SELECTED));
check.add(new AjaxFormComponentUpdatingBehavior("change") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
// nothing, just update model.
}
});
item.add(check);
AjaxLink<Void> propLink = new AjaxLink<Void>(ID_PROP_LINK) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
addOneItemPerformed(item.getModelObject(), target);
}
};
item.add(propLink);
Label name = new Label(ID_PROP_NAME, new PropertyModel<>(item.getModel(), SearchItemDefinition.F_NAME));
name.setRenderBodyOnly(true);
propLink.add(name);
Label help = new Label(ID_HELP);
IModel<String> helpModel = new PropertyModel<>(item.getModel(), SearchItemDefinition.F_HELP);
help.add(AttributeModifier.replace("title", createStringResource(helpModel.getObject() != null ? helpModel.getObject() : "")));
help.add(new InfoTooltipBehavior() {
@Override
public String getDataPlacement() {
return "left";
}
});
help.add(new VisibleBehaviour(() -> StringUtils.isNotEmpty(helpModel.getObject())));
item.add(help);
item.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
SearchItemDefinition property = item.getModelObject();
Search<C> search = SearchPanel.this.getModelObject();
if (!search.getAvailableDefinitions().contains(property)) {
return false;
}
for (SearchItem searchItem : search.getItems()) {
if (searchItem.getDefinition().equals(property)) {
return false;
}
if (searchItem instanceof PropertySearchItem) {
ItemPath propertyPath = property.getPath();
if (propertyPath != null && QNameUtil.match(propertyPath.lastName(), ((PropertySearchItem) searchItem).getPath().lastName())) {
return false;
}
}
}
MoreDialogDto dto = moreDialogModel.getObject();
String nameFilter = dto.getNameFilter();
String propertyName = property.getName().toLowerCase();
if (StringUtils.isNotEmpty(nameFilter) && !propertyName.contains(nameFilter.toLowerCase())) {
return false;
}
return true;
}
});
}
};
propList.add(properties);
TextField<?> addText = new TextField<>(ID_ADD_TEXT, new PropertyModel<>(moreDialogModel, MoreDialogDto.F_NAME_FILTER));
addText.add(WebComponentUtil.preventSubmitOnEnterKeyDownBehavior());
popover.add(addText);
addText.add(new AjaxFormComponentUpdatingBehavior("keyup") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(propList);
}
});
popover.add(addText);
AjaxButton add = new AjaxButton(ID_ADD, createStringResource("SearchPanel.add")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
addItemPerformed(target);
}
};
popover.add(add);
AjaxButton close = new AjaxButton(ID_CLOSE, createStringResource("SearchPanel.close")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
closeMorePopoverPerformed(target);
}
};
popover.add(close);
}
use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class MidPointApplication method isPostMethodTypeBehavior.
private boolean isPostMethodTypeBehavior(AbstractDefaultAjaxBehavior behavior, AjaxRequestAttributes attributes) {
if (behavior instanceof AjaxFormComponentUpdatingBehavior) {
// these also uses POST, but they set it after this method is called
return true;
}
if (behavior instanceof AjaxFormSubmitBehavior) {
AjaxFormSubmitBehavior fb = (AjaxFormSubmitBehavior) behavior;
Form form = fb.getForm();
String formMethod = form.getMarkupAttributes().getString("method");
if (formMethod == null || "POST".equalsIgnoreCase(formMethod) || form.getRootForm().isMultiPart()) {
// this will also use POST
return true;
}
}
return AjaxRequestAttributes.Method.POST.equals(attributes.getMethod());
}
use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class NameStep method createConnectorDropDown.
private DropDownFormGroup<PrismObject<ConnectorType>> createConnectorDropDown() {
return new DropDownFormGroup<PrismObject<ConnectorType>>(ID_CONNECTOR, selectedConnectorModel, relevantConnectorsModel, new IChoiceRenderer<PrismObject<ConnectorType>>() {
@Override
public PrismObject<ConnectorType> getObject(String id, IModel<? extends List<? extends PrismObject<ConnectorType>>> choices) {
return StringUtils.isNotBlank(id) ? choices.getObject().get(Integer.parseInt(id)) : null;
}
@Override
public Object getDisplayValue(PrismObject<ConnectorType> object) {
return WebComponentUtil.getName(object);
}
@Override
public String getIdValue(PrismObject<ConnectorType> object, int index) {
if (index < 0) {
// noinspection unchecked
List<PrismObject<ConnectorType>> connectors = (List<PrismObject<ConnectorType>>) getConnectorDropDown().getInput().getChoices();
for (PrismObject<ConnectorType> connector : connectors) {
if (connector.getOid().equals(selectedConnectorModel.getObject().getOid())) {
return Integer.toString(connectors.indexOf(connector));
}
}
}
return Integer.toString(index);
}
}, createStringResource("NameStep.connectorType"), "col-md-3", "col-md-6", true) {
@Override
protected DropDownChoice<PrismObject<ConnectorType>> createDropDown(String id, IModel<List<PrismObject<ConnectorType>>> choices, IChoiceRenderer<PrismObject<ConnectorType>> renderer, boolean required) {
DropDownChoice<PrismObject<ConnectorType>> choice = super.createDropDown(id, choices, renderer, required);
choice.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(getConnectorDropDown().getAdditionalInfoComponent());
}
});
choice.setOutputMarkupId(true);
return choice;
}
@Override
protected Component createAdditionalInfoComponent(String id) {
Label l = new Label(id, schemaChangeWarningModel);
l.add(new AttributeAppender("class", "text-danger"));
l.setOutputMarkupId(true);
return l;
}
};
}
use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.
the class NameStep method createHostDropDown.
@NotNull
private DropDownFormGroup<PrismObject<ConnectorHostType>> createHostDropDown() {
return new DropDownFormGroup<PrismObject<ConnectorHostType>>(ID_CONNECTOR_HOST, selectedHostModel, allHostsModel, new IChoiceRenderer<PrismObject<ConnectorHostType>>() {
@Override
public PrismObject<ConnectorHostType> getObject(String id, IModel<? extends List<? extends PrismObject<ConnectorHostType>>> choices) {
if (StringUtils.isBlank(id)) {
return null;
}
return choices.getObject().get(Integer.parseInt(id));
}
@Override
public Object getDisplayValue(PrismObject<ConnectorHostType> object) {
if (object == null) {
return NameStep.this.getString("NameStep.hostNotUsed");
}
return ConnectorHostTypeComparator.getUserFriendlyName(object);
}
@Override
public String getIdValue(PrismObject<ConnectorHostType> object, int index) {
return Integer.toString(index);
}
}, createStringResource("NameStep.connectorHost"), "col-md-3", "col-md-6", false) {
@Override
protected DropDownChoice<PrismObject<ConnectorHostType>> createDropDown(String id, IModel<List<PrismObject<ConnectorHostType>>> choices, IChoiceRenderer<PrismObject<ConnectorHostType>> renderer, boolean required) {
DropDownChoice<PrismObject<ConnectorHostType>> choice = super.createDropDown(id, choices, renderer, required);
choice.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
discoverConnectorsPerformed(target);
}
});
return choice;
}
};
}
Aggregations