From e598b2540bc9e06e94ca18fbad0d4fc20a7d224f Mon Sep 17 00:00:00 2001
From: srosse <stephane.rosse@frentix.com>
Date: Wed, 22 May 2019 15:47:46 +0200
Subject: [PATCH] OO-4015: fix generic selection rendering

---
 .../GenericSelectionPropertyHandler.java          | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/olat/user/propertyhandlers/GenericSelectionPropertyHandler.java b/src/main/java/org/olat/user/propertyhandlers/GenericSelectionPropertyHandler.java
index 543391e734c..73b2a4284ce 100644
--- a/src/main/java/org/olat/user/propertyhandlers/GenericSelectionPropertyHandler.java
+++ b/src/main/java/org/olat/user/propertyhandlers/GenericSelectionPropertyHandler.java
@@ -207,6 +207,11 @@ public class GenericSelectionPropertyHandler extends AbstractUserPropertyHandler
 		return (value == null ? NO_SEL_KEY : value);
 	}
 
+	@Override
+	public String getUserProperty(User user, Locale locale) {
+		return getUserPropertyAsHTML(user, locale);
+	}
+
 	@Override
 	public void updateUserFromFormItem(User user, FormItem formItem) {
 		String internalValue = getStringValue(formItem);
@@ -287,17 +292,15 @@ public class GenericSelectionPropertyHandler extends AbstractUserPropertyHandler
 
 	@Override
 	public String getUserPropertyAsHTML(User user, Locale locale) {
+		String val = super.getInternalValue(user);// don't want "no selection" key
 		StringBuilder htmlValue = new StringBuilder();
 		Translator trans = Util.createPackageTranslator(this.getClass(), locale);
 		if (isMultiSelect()) {
-			for (String value : getInternalValue(user).split(KEY_DELIMITER)) {
+			for (String value : val.split(KEY_DELIMITER)) {
 				htmlValue.append(trans.translate(value)).append(" ");
 			}
-		} else {
-			String val = getInternalValue(user);
-			if(val != null && locale != null) {
-				htmlValue.append(trans.translate(val));
-			}
+		} else if(val != null && locale != null) {
+			htmlValue.append(trans.translate(val));
 		}
 		return htmlValue.toString();
 	}
-- 
GitLab