if (alt == null) {
log
.error("No alternative selected. This method should not have been called.");
return;
}
AlternativesDefinition alternativesDefinition = selectedPlan.getAlternativesDefinition();
// its a new alternative and the alternative is not yet in list of
// alternatives
// note: the user can also edit an alternative that has already been added to the list
if ((alt.getId() == 0) &&
(!alternativesDefinition.getAlternatives().contains(alt))) {
String altName = alt.getName();
if ((altName.length() > 20)||
(null != alternativesDefinition.alternativeByName(altName))){
FacesMessages.instance()
.add(FacesMessage.SEVERITY_ERROR,
"Please provide a unique name which has no more than 20 characters.");
return;
}
// add it to the preservation planning project
alternativesDefinition.addAlternative(alt);
// refresh the datamodel list
alternativeList = alternativesDefinition.getAlternatives();
// the alternativesdefinition has been changed
alternativesDefinition.touch();
}
// this alternative has been changed
alt.touch();
// exit editing mode