jcr:title being saved as String[] on changing and saving page properties; causes "Manage Publication" Touch UI dialog to break | Community
Skip to main content
this-that-the-otter
Level 4
February 11, 2025
Solved

jcr:title being saved as String[] on changing and saving page properties; causes "Manage Publication" Touch UI dialog to break

  • February 11, 2025
  • 1 reply
  • 1223 views

We're seeing an issue with a few of our templates where if the page properties are edited (within Touch UI "Properties") after initial page creation, the jcr:title field property type will be changed from String to String[], the jcr:title field will then contain 2 identical jcr:title values (we see this in /crx/de). Whatever was there initially is repeated into a second value.

 

This then breaks the "Manage Publication" dialog within the Touch UI. The article for which one tries to "Manage Publication" cannot be selected in the dialog or added for publishing or unpublishing, it shows as a checkbox but no article is displayed in the listing, and when attempting to add the same article (via the button to add items within the "Manage Publication" dialog), it reports it cannot be added because it's already there, though it doesn't show up.

 

Changing jcr:title from String[] back to String by removing the property and re-adding it (in /crx/de) fixes the issue until the article's page properties might be edited again.


I've looked at related template code searching for any instance of String[] but only see one for an unrelated field (i.e. tags) which makes sense as multiple tags can be assigned.

 

Has anyone seen similar behavior with a property / field changing it's definition / type? Thanks for any info on how to debug and fix!

Best answer by Kamal_Kishor

Hi @kamal_kishor ; 

 

I removed the listener java/class it didn't change the behavior, I tried the template/component in different paths of the site (after changing allowedPaths), and saw the same behavior.

I asked Google Gemini: 

https://www.google.com/search?q=aem+property+changing+its+type+from+string+to+string+array

Answer:

When a property in AEM unexpectedly changes its type from String to String[], it usually occurs when the field associated with the property allows multiple values. If a user initially saves a single value, AEM creates a String property. However, upon saving multiple values, AEM automatically converts the property type to String[].
To handle this behavior, consider these approaches:
  • TypeHint: Utilize the @TypeHint suffix in the property name within the dialog to explicitly define the property type as String[]. This ensures that AEM always treats the property as a String array, even when only a single value is initially saved. For example:

 

 

<myProperty jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/textfield" name="./myProperty"/> <myPropertyTypeHint jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/hidden" name="./myProperty@TypeHint" value="String[]"/>

 

 

There are two templates/components where we are seeing the issue. In both I made what seem like the same 2 changes: 

 

In _cq_dialog/.content.xml

From:

 

<items jcr:primaryType="nt:unstructured"> <title jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/textfield" fieldLabel="Title" name="./jcr:title"/> <shortTitle ...

 

To:

 

<items jcr:primaryType="nt:unstructured"> <title jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/textfield" fieldLabel="Title" name="./jcr:title@TypeHint" value="String"/> <shortTitle ...

 

 

And in the tabs_component.xml 

From:

 

<title jcr:primaryType="cq:Widget" fieldLabel="Title" name="./jcr:title" xtype="textfield"/> <shortTitle ...

 

To:

 

<title jcr:primaryType="cq:Widget" fieldLabel="Title" name="./jcr:title@TypeHint" value="String" xtype="textfield"/> <shortTitle ...

 

 

This seems to completely fix the issue for one of our templates/components - but in the other, while jcr:title remains a String even after editing properties, and the Manage Publication dialog continues to work (even after editing properties), the word "String" shows up as a value in one of the Title fields? 

 

Thank you again for any help.


You are right. Setting typehint to String should fix it.

 

1 reply

Kamal_Kishor
Community Advisor
Community Advisor
February 11, 2025

@this-that-the-otter : This can happen if you have specified a typehint for your property or some specific type of field values.

Can you check if there is a @TypeHint set for jcr:title property (ideally should not be the case).
If not, can you share what kind of values are being set on title field.

thanks.

this-that-the-otter
Level 4
February 11, 2025

@kamal_kishor: Thank you for replying! I do see @TypeHint in related code but not for jcr:title. The @TypeHint looks to be used to set on/off time, whose fields, along with title, are present in the page "Properties" dialog. Here's a glimpse of how the jcr:title is mentioned in the component code which I believe is rendering the page "Properties" dialog: 

 

<items jcr:primaryType="cq:WidgetCollection"> <title jcr:primaryType="cq:Widget" fieldLabel="Title" name="./jcr:title" xtype="textfield"/> <shortTitle ...

 

further down in the same file ...

 

<onofftime jcr:primaryType="cq:Widget" cls="cq-propsdialog-set-onofftime" collapsed="{Boolean}true" collapsible="{Boolean}true" hideMode="offsets" title="On/Off Time" xtype="dialogfieldset"> <items jcr:primaryType="cq:WidgetCollection"> <ontime jcr:primaryType="cq:Widget" ctCls="cq-propsdialog-ontime" fieldLabel="On Time" name="./onTime" xtype="datetime"/> <offtime jcr:primaryType="cq:Widget" ctCls="cq-propsdialog-offtime" fieldLabel="Off Time" name="./offTime" xtype="datetime"/> <onTimeHint jcr:primaryType="cq:Widget" ignoreData="{Boolean}true" name="./onTime@TypeHint" value="Date" xtype="hidden"/> <offTimeHint jcr:primaryType="cq:Widget" ignoreData="{Boolean}true" name="./offTime@TypeHint" value="Date" xtype="hidden"/> </items> </onofftime> </items> </jcr:root>

 

Thanks again.

 

Kamal_Kishor
Community Advisor
Community Advisor
February 12, 2025

@this-that-the-otter : Ok, so TypeHint does not seem to be the issue here.
Can you please tell us how are you updating the title value and if this issue occurs only with specific type of values or with any title string value?
I am also wondering if you have any script/backend-code trying to update the title for your pages.
This looks bit odd since ideally this should not occur.

thank you.