Skip to content

The Unified and Autonomous Development Platform

chore: Fix a minor polymorphic editor issue

Robin Shen71279d18735a
diff --git a/server-core/src/main/java/io/onedev/server/web/component/polymorphiceditor/PolymorphicEditor.java b/server-core/src/main/java/io/onedev/server/web/component/polymorphiceditor/PolymorphicEditor.java
index 4f7c24259c..e765a9aedf 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/polymorphiceditor/PolymorphicEditor.java
+++ b/server-core/src/main/java/io/onedev/server/web/component/polymorphiceditor/PolymorphicEditor.java
@@ -11,6 +11,7 @@ import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.behavior.AttributeAppender;
+import org.apache.wicket.event.IEvent;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.DropDownChoice;
@@ -204,6 +205,16 @@ public class PolymorphicEditor extends ValueEditor<Serializable> {
super.error(propertyNode, pathInProperty, errorMessage);
}
+ @Override
+ public void onEvent(IEvent<?> event) {
+ super.onEvent(event);
+
+ if (event.getPayload() instanceof BeanUpdating) {
+ convertInput();
+ clearErrors();
+ }
+ }
+
@Override
protected Serializable convertInputToValue() throws ConversionException {
Component beanEditor = get("beanEditor");
diff --git a/server-core/src/main/java/io/onedev/server/web/editable/BeanEditor.java b/server-core/src/main/java/io/onedev/server/web/editable/BeanEditor.java
index 122947c61d..9180ea5521 100644
--- a/server-core/src/main/java/io/onedev/server/web/editable/BeanEditor.java
+++ b/server-core/src/main/java/io/onedev/server/web/editable/BeanEditor.java
@@ -89,7 +89,7 @@ public class BeanEditor extends ValueEditor<Serializable> {
* Create new property container instead of simply refreshing it as some dependent
* properties may only take effect when re-create the property container. For instance
* If default value of an issue field depends on input value of another issue field
- */
+ */
PropertyContainer newPropertyContainer =
newPropertyContainer(propertyContainer.getId(), propertyContext);
propertyContainer.replaceWith(newPropertyContainer);