*
* @param link the link model object
*/
private void addNewFormLink(int index, final LLModel link) {
// add link target
TextElement lTarget = uifactory.addTextElement("target" + counter, null, -1, link.getTarget(), titleContainer);
lTarget.clearError();
lTarget.setDisplaySize(40);
lTarget.setMandatory(true);
lTarget.setNotEmptyCheck("ll.table.target.error");
lTarget.setItemValidatorProvider(new ItemValidatorProvider() {
public boolean isValidValue(String value, ValidationError validationError, @SuppressWarnings("unused") Locale locale) {
try {
if (!value.contains("://")) {
value = "http://".concat(value);
}
new URL(value);
} catch (MalformedURLException e) {
validationError.setErrorKey("ll.table.target.error.format");
return false;
}
return true;
}
});
lTarget.addActionListener(this, FormEvent.ONCHANGE);
lTarget.setUserObject(link);
lTargetInputList.add(index, lTarget);
//add html target
MultipleSelectionElement htmlTargetSelection = uifactory.addCheckboxesHorizontal("html_target" + counter, titleContainer, new String[]{BLANK_KEY}, new String[]{""}, null);
htmlTargetSelection.setUserObject(link);
htmlTargetSelection.select(BLANK_KEY, "_blank".equals(link.getHtmlTarget()));
lHtmlTargetInputList.add(index, htmlTargetSelection);
// add link description
TextElement lDescription = uifactory.addTextElement("description" + counter, null, -1, link.getDescription(), titleContainer);
lDescription.clearError();
lDescription.setDisplaySize(20);
lDescription.setNotEmptyCheck("ll.table.description.error");
lDescription.setMandatory(true);
lDescription.setUserObject(link);
lDescriptionInputList.add(index, lDescription);
// add link comment
TextElement lComment =uifactory.addTextElement("comment" + counter, null, -1, link.getComment(), titleContainer);
lComment.setDisplaySize(20);
lComment.setUserObject(link);
lCommentInputList.add(index, lComment);
// add link add action button
FormLink addButton = new FormLinkImpl("add" + counter, "add" + counter, "ll.table.add", Link.BUTTON_SMALL);
addButton.setUserObject(link);