private void fetchLocalizedFields() {
Iterator<Lang> itr = this.getLangManager().getLangs().iterator();
Survey survey = null;
try {
while (itr.hasNext()) {
Lang currentLang = itr.next();
Lang defaultLanguage = this.getLangManager().getDefaultLang();
String currentLangCode = currentLang.getCode();
String titleKey = "title-" + currentLangCode;
String descriptionKey = "description-" + currentLangCode;
String imageDescriptionKey = "imageDescription-" + currentLangCode;
String title = this.getRequest().getParameter(titleKey);
String description = this.getRequest().getParameter(descriptionKey);
String imageDescription = this.getRequest().getParameter(imageDescriptionKey);
if (null != title && title.trim().length() > 0) {
this.getTitles().put(currentLangCode, title.trim());
} else {
if (currentLang.getCode().equals(defaultLanguage.getCode())) {
String[] args = { defaultLanguage.getDescr(), this.getText("title") };
this.addFieldError(titleKey, this.getText("message.jpsurvey.defaultLangRequired", args));
}
}
if (null != description && description.trim().length() > 0) {
this.getDescriptions().put(currentLangCode, description.trim());
} else {
if (currentLang.getCode().equals(defaultLanguage.getCode())) {
String[] args = { defaultLanguage.getDescr(), this.getText("description") };
this.addFieldError(descriptionKey, this.getText("message.jpsurvey.defaultLangRequired", args));
}
}
if (this.getStrutsAction() == ApsAdminSystemConstants.EDIT) {
// image description is required if and only if an image has been associated to the current editing _survey
survey = this.getSurveyManager().loadSurvey(this.getSurveyId());
// there shouldn't be the need to check for the lenght of the imageId...
if (null != survey && null != survey.getImageId()) {
if (null != imageDescriptionKey && null != imageDescription && imageDescription.trim().length() > 0) {
this.getImageDescriptions().put(currentLangCode, imageDescription.trim());
} else {
if (currentLang.getCode().equals(defaultLanguage.getCode())) {
String[] args = { defaultLanguage.getDescr(), this.getText("imageDescription") };
this.addFieldError(imageDescriptionKey, this.getText("message.jpsurvey.defaultLangRequired", args));
}
}
}
}