Media Handler - File Upload Component - problem saving fileReference
Description
Activity
Stefan Seifert February 24, 2020 at 4:33 PM
fixed in Media Handler 1.9.0 with this PR
Stefan Seifert February 24, 2020 at 3:54 PM
provided a PR: https://github.com/wcm-io/wcm-io-handler/pull/16

Benjamin Kalbitz February 19, 2020 at 11:28 AM
The problem lies in wcm-io/handler/media/components/granite/form/fileupload
where two components are merged together
cq/gui/components/authoring/dialog/fileupload
wcm-io/wcm/ui/granite/components/form/pathfield
Both Components holds an input field for './fielReference'
cq/gui/components/authoring/dialog/fileupload has a javascript function that deletes duplicated input fields _removeDuplicateHiddenInputs when the component is created
So the composition of both components works most of the time. But, when the component is saved without an image and opened again, cq/gui/components/authoring/dialog/fileupload holds the input field instead of wcm-io/wcm/ui/granite/components/form/pathfield.
This could be because wcm-io/wcm/ui/granite/components/form/pathfield has no './fielReference' input field at this time or the _removeDuplicateHiddenInputs function removes the field in another order.
When an image is then dropped in the component wcm-io/wcm/ui/granite/components/form/pathfield also gets a './fielReference' input field. So the value is posted twice.
Details
Details
Assignee
Reporter

Intro
There is a case that
fileReference
is set as an array in the JCR.This happens when there is an image, which already has an asset set, editing it, clearing the reference and setting a new image.
Reproduction
Setup a new AEM 6.5 author on port 4502
Create a sample project using wcm.io archetype
https://wcm.io/tooling/maven/archetypes/aem/usage.html
Using example from "AEM project with wcm.io and Sling-Initial-Content project layout and Java 11"
Install the sample project “./build-deploy.sh”
Open http://localhost:4502/editor.html/content/myproject1/en.html
Add an image component, set an image, save
Edit that component, press “Clear”, save
Edit that component, set an image, save
Open http://localhost:4502/crx/de/index.jsp#/content/myproject1/en/jcr%3Acontent/root/content/image
Actual behavior
fileReference
String[]
/content/dam/myproject1/prague.jpg, /content/dam/myproject1/prague.jpg
Expected behavior
fileReference
String
/content/dam/myproject1/prague.jpg
Side note
I tried the Adobe core component:
http://localhost:4502/crx/de/index.jsp#/apps/myproject1/core/components/content/image
set
sling:resourceSuperType
tocore/wcm/components/image/v2/image
The problem does not occur