Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Error in Displaying multifield value

Avatar

Level 2

Mandar_Hambhire_0-1654768064372.png

 

cq:dilog code

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="nt:unstructured"
jcr:title="Properties"
sling:resourceType="cq/gui/components/authoring/dialog">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<accordion
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
composite="{Boolean}true"
fieldLabel="News">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
name="./multifield">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<description
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldLabel="Description"
name="./title"/>
</items>
</column>
</items>
</field>
</accordion>
</items>
</column>
</items>
</content>
</jcr:root>


htl code
<pre data-sly-use.hello="com.aem.HDFC_GIGA.core.models.ArticalCardValueModel">
<sly data-sly-list="${hello.articles.listChildren}">
HelloWorldModel says: ${item.title}
</sly>

</pre>

 

9 Replies

Avatar

Community Advisor

Hi,

what is the issue? what results are you getting and what is expected?

Can you also share the Sling Model code?

Avatar

Level 2

i want value to be stored as individual node

Mandar_Hambhire_0-1654839788104.png

 

but it get stored inside parent node

package com.aem.HDFC_GIGA.core.models;

import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Optional;
import org.apache.sling.settings.SlingSettingsService;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;

@Model(adaptables=Resource.class)
public class ArticalCardValueModel {

@Inject
@Optional
private Resource multifield;




@PostConstruct
protected void init() {

}


}

 

Avatar

Community Advisor

Hi,

Code looks fine. The node structure should be created with this.

Can you check if you have override the 

granite/ui/components/coral/foundation/form/multifield

 

Avatar

Community Advisor

with resource override, did you change the logic? what was the reason for override.

Avatar

Level 2

Sorry, i make mistake in understanding yours Question i have only use that resource type to create multifield

Avatar

Community Advisor

I feel author's entries like title are getting stored as a multi value property (String[]) and because of it you are facing the issue. Please correct me.

I have tested with your .content.xml associated with cq:dialog and author's entries are getting stored as individual nodes as shown below -

 

DEBAL_DAS_0-1654796193209.png

composite="{Boolean}true" supports this node structure. Could you please test the component on different page and share your observation with error details.

Avatar

Level 2

@Inject
@Optional
private Resource multifield;

now i change "private to public" and now i am able to fetch ad display the value  on page

Mandar_Hambhire_0-1654841108811.png

 

but still not getting the node structure

Mandar_Hambhire_1-1654841140542.png

 

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now