This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 43cf251b21 ISIS-3071: fixes proposed value recovery for FileUpload
43cf251b21 is described below
commit 43cf251b2199720858106f86e86dcef6aa7039f2
Author: Andi Huber <[email protected]>
AuthorDate: Mon Sep 26 19:52:13 2022 +0200
ISIS-3071: fixes proposed value recovery for FileUpload
---
.../viewer/wicket/ui/components/scalars/_Util.java | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/_Util.java
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/_Util.java
index 034ed03846..74218f57a2 100644
---
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/_Util.java
+++
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/scalars/_Util.java
@@ -128,22 +128,31 @@ class _Util {
return true;
}
+ //XXX its rather unfortunate, that this method has to deal with 4
different cases
private Optional<ManagedObject> recoverProposedValue(
final Object valueObject,
final ScalarModel scalarModel){
if(valueObject instanceof Collection) {
+
+ if(scalarModel.isSingular()) {
+ // seeing this code-path with FileUpload being wrapped in an
ArrayList of size 1
+ // as a more general rule of thumb, use the first element in
the ArrayList if present
+ val unpackedValue = ((Collection<?>)valueObject).stream()
+ .limit(1)
+ .map(v->scalarModel.getObjectManager()
+ .adapt(valueObject))
+ .findFirst();
+ return unpackedValue;
+ }
+
val unpackedValues = ((Collection<?>)valueObject).stream()
.map(v->scalarModel
- .getObjectManager().demementify((ObjectMemento)v))
+ .getObjectManager().demementify((ObjectMemento)v))
.collect(Can.toCan());
return
Optional.of(ManagedObject.packed(scalarModel.getScalarTypeSpec(),
unpackedValues));
}
-// if(scalarModel.isPlural()) {
-// _Assert.assertTrue(valueObject instanceof ObjectMemento,
()->"unexpected code path???");
-// }
-
if(valueObject instanceof ObjectMemento) {
// seeing this code-path particularly with enum choices
return Optional.ofNullable(
@@ -157,6 +166,7 @@ class _Util {
.adapt(valueObject));
}
+
// -- HELPER
private Optional<ObjectAction> lookupCompositeValueMixinForFeature(final
ScalarModel scalarModel) {