private static final long serialVersionUID = -4804368561204623354L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
entityTO.getDerivedAttributes().add(new AttributeTO());
target.add(attributesContainer);
}
@Override
protected void onError(final AjaxRequestTarget target, final Form<?> form) {
target.add(attributesContainer);
}
};
add(addAttributeBtn.setDefaultFormProcessing(Boolean.FALSE));
final ListView<AttributeTO> attributes = new ListView<AttributeTO>("attributes",
new PropertyModel<List<? extends AttributeTO>>(entityTO, "derivedAttributes")) {
private static final long serialVersionUID = 9101744072914090143L;
@Override
protected void populateItem(final ListItem<AttributeTO> item) {
final AttributeTO attributeTO = item.getModelObject();
item.add(new AjaxDecoratedCheckbox("toRemove", new Model<Boolean>(Boolean.FALSE)) {
private static final long serialVersionUID = 7170946748485726506L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
entityTO.getDerivedAttributes().remove(attributeTO);
target.add(attributesContainer);
}
@Override
protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
IAjaxCallListener ajaxCallListener = new AjaxCallListener() {
private static final long serialVersionUID = 7160235486520935153L;
@Override
public CharSequence getPrecondition(final Component component) {
return "if (!confirm('" + getString("confirmDelete") + "')) return false;";
}
};
attributes.getAjaxCallListeners().add(ajaxCallListener);
}
});
final DropDownChoice<String> schemaChoice = new DropDownChoice<String>("schema",
new PropertyModel<String>(attributeTO, "schema"), derivedSchemaNames);
schemaChoice.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_BLUR) {
private static final long serialVersionUID = -1107858522700306810L;
@Override
protected void onUpdate(final AjaxRequestTarget art) {
attributeTO.setSchema(schemaChoice.getModelObject());
}
});
item.add(schemaChoice.setRequired(true));
schemaChoice.setOutputMarkupId(true);
schemaChoice.setRequired(true);
item.add(schemaChoice);
final List<String> values = attributeTO.getValues();
if (values == null || values.isEmpty()) {
item.add(new TextField<String>("value",
new Model<String>(null)).setVisible(Boolean.FALSE));
} else {
item.add(new TextField<String>("value",