setOutputMarkupId(true);
entityLink.setOutputMarkupId(true);
entityLink.setLabel(Model.of(name));
final FormGroup labelIfRegular = new FormGroup(ID_SCALAR_IF_REGULAR, entityLink);
labelIfRegular.add(entityLink);
final String describedAs = getModel().getDescribedAs();
if(describedAs != null) {
labelIfRegular.add(new AttributeModifier("title", Model.of(describedAs)));
}
final Label scalarName = new Label(ID_SCALAR_NAME, getRendering().getLabelCaption(entityLink));
labelIfRegular.add(scalarName);
applyLabelAtRule(scalarName, labelIfRegular);
addOrReplace(labelIfRegular);
addFeedbackTo(labelIfRegular, entityLink);
addAdditionalLinksTo(labelIfRegular);
// add semantics
entityLink.setRequired(getModel().isRequired());
entityLink.add(new IValidator<ObjectAdapter>() {
private static final long serialVersionUID = 1L;
@Override
public void validate(final IValidatable<ObjectAdapter> validatable) {
final ObjectAdapter proposedAdapter = validatable.getValue();
final String reasonIfAny = getModel().validate(proposedAdapter);
if (reasonIfAny != null) {
final ValidationError error = new ValidationError();
error.setMessage(reasonIfAny);
validatable.error(error);
}
}
});
if(getModel().isRequired()) {
labelIfRegular.add(new CssClassAppender("mandatory"));
}
return labelIfRegular;
}