Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

AEM6.3 Touch ui autocomplete coral tags storing as String instead of String[] required for classic dialog

Avatar

Level 8

Hi ,

We are using  AEM6.3 both classic and touch ui dialog.

When using the below autocomplete for tags it storing in crxde as string instead of string[] when i just select one tag .Due to this when i open the same in classic dialog the tags don't come up as it expects String[].

Please could you provide inputs as how to fix it.

The component i am using is

<tag

         jcr:primaryType="nt:unstructured"

         sling:resourceType="granite/ui/components/coral/foundation/form/autocomplete"

         fieldLabel=" Asset Tags"

          multiple="{Boolean}true"

         name="./assetTags"

         mode="contains">

          <datasource

           jcr:primaryType="nt:unstructured"

           sling:resourceType="cq/gui/components/common/datasources/tags"/>

          <options

           jcr:primaryType="nt:unstructured"

           sling:resourceType="granite/ui/components/coral/foundation/form/autocomplete/list"/>

          <values

           jcr:primaryType="nt:unstructured"

           sling:resourceType="granite/ui/components/coral/foundation/form/autocomplete/tags"/>

                                    </tag>

Classic UI:-

1803236_pastedImage_6.png

Touch UI:-

I am selecting just one tag it stores as  assetTags String instead od String[]

1803228_pastedImage_1.png

1 Accepted Solution

Avatar

Correct answer by
Level 6

Hi srinivas channappa​,

This works for me although I tested in AEM 6.4

Parallel to your tag node create another node called tag-hint with same name as the original node followed by "@TypeHint" as shown below:

                         <tag-hint

                               jcr:primaryType="nt:unstructured"

                                sling:resourceType="granite/ui/components/coral/foundation/form/hidden"

                               value="String[]"

                                ignoreData="{Boolean}true"

                                name="./assetTags@TypeHint">

                            </tag-hint>

1803271_pastedImage_5.png

1803269_pastedImage_2.png

As mentioned in the documentation:

@TypeHint

Parameters with the @TypeHint suffix may be used to force storing the named parameter in a property with the given type. The value of the @TypeHint parameter, if applied to a parameter for a property, is the JCR property type name. If the @TypeHint parameter is applied to a field upload parameter, the value is used to indicate the JCR primary node type for the node into which the uploaded file is stored.

If the @TypeHint value ends with [], it indicates a multi-value property. A multi-value property is usually auto-detected if there are multiple values for the property (i.e. request parameter). But if only a single value is present in the request, the desired property type needs to be explicitly defined as multi-value by stating @TypeHint=<type>[].

For more info check this:

https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-po...

https://www.argildx.com/technology/how-to-change-data-type-typecast-in-aem-use-typehint

View solution in original post

2 Replies

Avatar

Correct answer by
Level 6

Hi srinivas channappa​,

This works for me although I tested in AEM 6.4

Parallel to your tag node create another node called tag-hint with same name as the original node followed by "@TypeHint" as shown below:

                         <tag-hint

                               jcr:primaryType="nt:unstructured"

                                sling:resourceType="granite/ui/components/coral/foundation/form/hidden"

                               value="String[]"

                                ignoreData="{Boolean}true"

                                name="./assetTags@TypeHint">

                            </tag-hint>

1803271_pastedImage_5.png

1803269_pastedImage_2.png

As mentioned in the documentation:

@TypeHint

Parameters with the @TypeHint suffix may be used to force storing the named parameter in a property with the given type. The value of the @TypeHint parameter, if applied to a parameter for a property, is the JCR property type name. If the @TypeHint parameter is applied to a field upload parameter, the value is used to indicate the JCR primary node type for the node into which the uploaded file is stored.

If the @TypeHint value ends with [], it indicates a multi-value property. A multi-value property is usually auto-detected if there are multiple values for the property (i.e. request parameter). But if only a single value is present in the request, the desired property type needs to be explicitly defined as multi-value by stating @TypeHint=<type>[].

For more info check this:

https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-po...

https://www.argildx.com/technology/how-to-change-data-type-typecast-in-aem-use-typehint

Avatar

Level 8

Thanks for helping me out on fixing this issue.