url.add(new UrlValidator());
url.setRequired(true);
urlBorder.add(url);
// remove link
AjaxLink link = new AjaxLink("removeLink", item.getModel()) {
@Override
public void onClick(AjaxRequestTarget target) {
ResourceInfo ri = (ResourceInfo) resourceModel.getObject();
ri.getMetadataLinks().remove(getModelObject());
updateLinksVisibility();
target.addComponent(container);
}
};
item.add(link);
}
};
// this is necessary to avoid loosing item contents on edit/validation checks
links.setReuseItems(true);
table.add(links);
// the no metadata links label
noMetadata = new Label("noLinks", new ResourceModel("noMetadataLinksSoFar"));
container.add(noMetadata);
updateLinksVisibility();
// add new link button
AjaxButton button = new AjaxButton("addlink") {
@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
ResourceInfo ri = (ResourceInfo) resourceModel.getObject();
MetadataLinkInfo link = ri.getCatalog().getFactory().createMetadataLink();;
link.setMetadataType(LINK_TYPES.get(0));
link.setType("text/plain");
ri.getMetadataLinks().add(link);
updateLinksVisibility();
target.addComponent(container);
}