Skip to content

Commit 48d9be9

Browse files
committed
[MINOR] Handle Collection as defaultValue in GUI.select()
Improved GUI.select() method to properly handle Collection objects passed as defaultValue. When a Collection is provided, it now extracts the first element as the default value, preventing potential rendering issues in the UI.
1 parent a6fcb9d commit 48d9be9

File tree

1 file changed

+10
-0
lines changed
  • zeppelin-interpreter/src/main/java/org/apache/zeppelin/display

1 file changed

+10
-0
lines changed

zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/GUI.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,17 @@ public Object password(String id) {
9696
return params.get(id);
9797
}
9898

99+
/**
100+
* Create a select form.
101+
*
102+
* <p>If {@code defaultValue} is a {@link java.util.Collection} the first
103+
* element will be used as the actual default value.</p>
104+
*/
99105
public Object select(String id, ParamOption[] options, Object defaultValue) {
106+
if (defaultValue instanceof Collection && !(defaultValue instanceof String)) {
107+
Collection<?> values = (Collection<?>) defaultValue;
108+
defaultValue = values.isEmpty() ? null : values.iterator().next();
109+
}
100110
if (defaultValue == null && options != null && options.length > 0) {
101111
defaultValue = options[0].getValue();
102112
}

0 commit comments

Comments
 (0)