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 c90e72c9c8 ISIS-3203: workaround converted input state out of sync
issue
c90e72c9c8 is described below
commit c90e72c9c889851b6c836197a864f24377b95373
Author: Andi Huber <[email protected]>
AuthorDate: Thu Sep 8 21:30:29 2022 +0200
ISIS-3203: workaround converted input state out of sync issue
- not a proper fix, but will have to do for now
---
.../wicket/model/models/FileUploadModels.java | 11 ++++++----
.../org/apache/isis/viewer/wicket/ui/util/Wkt.java | 24 +++++++++++++++++++++-
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git
a/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/FileUploadModels.java
b/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/FileUploadModels.java
index abd1c7e4f2..bad4ff1d3d 100644
---
a/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/FileUploadModels.java
+++
b/viewers/wicket/model/src/main/java/org/apache/isis/viewer/wicket/model/models/FileUploadModels.java
@@ -19,6 +19,7 @@
package org.apache.isis.viewer.wicket.model.models;
import java.nio.charset.Charset;
+import java.util.Collections;
import java.util.List;
import org.apache.wicket.markup.html.form.upload.FileUpload;
@@ -57,8 +58,9 @@ public class FileUploadModels {
@Override
protected List<FileUpload> fromScalarValue(final Blob blob) {
- // not used
- return null;
+ return blob!=null
+ ? Collections.emptyList() //[ISIS-3203] just enough so
we can distinguish the empty from the present case
+ : null;
}
};
@@ -92,8 +94,9 @@ public class FileUploadModels {
@Override
protected List<FileUpload> fromScalarValue(final Clob clob) {
- // not used
- return null;
+ return clob!=null
+ ? Collections.emptyList() //[ISIS-3203] just enough so
we can distinguish the empty from the present case
+ : null;
}
};
diff --git
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/util/Wkt.java
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/util/Wkt.java
index e8724ef0e2..624fd63150 100644
---
a/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/util/Wkt.java
+++
b/viewers/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/util/Wkt.java
@@ -18,6 +18,7 @@
*/
package org.apache.isis.viewer.wicket.ui.util;
+import java.util.Collections;
import java.util.List;
import java.util.OptionalInt;
import java.util.function.Supplier;
@@ -571,7 +572,28 @@ public class Wkt {
final String id,
final String initialCaption,
final IModel<List<FileUpload>> model) {
- val fileUploadField = new BootstrapFileInputField(id, model);
+ val fileUploadField = new BootstrapFileInputField(id, model) {
+ private static final long serialVersionUID = 1L;
+ @Override
+ public void convertInput() {
+ super.convertInput(); // keep side-effects
+ if(!isRequired()) {return;}
+ /*[ISIS-3203]: in the context of mandatory property or action
parameter negotiation,
+ * we need to set the converted input to something other than
null, even an empty list will do
+ */
+ if(isConvertedInputNull()
+ && !isModelEmpty()) {
+ super.setConvertedInput(Collections.emptyList()); //
always pass
+ }
+ }
+ @Override
+ public boolean checkRequired() {
+ super.checkRequired(); // keep side-effects
+ return true; // always pass otherwise workaround won't work
+ }
+ private boolean isModelEmpty() { return
getModel().getObject()==null; }
+ private boolean isConvertedInputNull() { return
getConvertedInput()==null; }
+ };
fileUploadField.getConfig()
.maxFileCount(1)
.mainClass("input-group-sm")