Multifield value is not coming in page | Community
Skip to main content
Level 3
July 27, 2020
Solved

Multifield value is not coming in page

  • July 27, 2020
  • 7 replies
  • 4284 views

Hi All,

I have one multi field and the value is not coming in my page.

 

**************My cq:dialog is below*************

<?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="Have Questions"
sling:resourceType="cq/gui/components/authoring/dialog">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<header
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="Installation Label"
fieldLabel="Installation Header"
name="./header"/>
<description
jcr:primaryType="nt:unstructured"
sling:resourceType="cq/gui/components/authoring/dialog/richtext"
fieldDescription="Installation Description"
fieldLabel="Installation Description"
name="./description"
useFixedInlineToolbar="{Boolean}true">
<uiSettings jcr:primaryType="nt:unstructured">
<cui jcr:primaryType="nt:unstructured">
<dialogFullScreen
jcr:primaryType="nt:unstructured"
toolbar="[format#bold,format#italic,format#underline,subsuperscript#subscript,subsuperscript#superscript,edit#cut,edit#copy,edit#paste-default,edit#paste-plaintext,edit#paste-wordhtml,links#modifylink,links#unlink,links#anchor,findreplace#find,findreplace#replace,undo#undo,undo#redo,justify#justifyleft,justify#justifycenter,justify#justifyright,justify#justifyjustify,lists#unordered,lists#ordered,lists#outdent,lists#indent,image#imageProps,spellcheck#checktext,generichtml#generichtml,misctools#specialchars,misctools#sourceedit,#styles,#paraformat,table#createoredit,table#removetable,table#removerow,table#removecolumn,table#mergecells,table#selectrow]">
<popovers jcr:primaryType="nt:unstructured">
<paraformat
jcr:primaryType="nt:unstructured"
items="paraformat:getFormats:paraformat-pulldown"
ref="paraformat"/>
</popovers>
</dialogFullScreen>
<tableEditOptions
jcr:primaryType="nt:unstructured"
toolbar="[table#insertcolumn-before,table#insertcolumn-after,table#removecolumn,-,table#insertrow-before,table#insertrow-after,table#removerow,-,table#mergecells-right,table#mergecells-down,table#mergecells,table#splitcell-horizontal,table#splitcell-vertical,-,table#selectrow,table#selectcolumn,-,table#ensureparagraph,-,table#modifytableandcell,table#removetable,-,undo#undo,undo#redo,-,table#exitTableEditing,-]"/>
<inline
jcr:primaryType="nt:unstructured"
toolbar="[format#bold,format#italic,format#underline,#justify,#lists,links#modifylink,links#unlink,#paraformat]">
<popovers jcr:primaryType="nt:unstructured">
<justify
jcr:primaryType="nt:unstructured"
items="[justify#justifyleft,justify#justifycenter,justify#justifyright]"
ref="justify"/>
<lists
jcr:primaryType="nt:unstructured"
items="[lists#unordered,lists#ordered,lists#outdent,lists#indent]"
ref="lists"/>
<paraformat
jcr:primaryType="nt:unstructured"
items="paraformat:getFormats:paraformat-pulldown"
ref="paraformat"/>
</popovers>
</inline>
</cui>
</uiSettings>
<rtePlugins jcr:primaryType="nt:unstructured">
<links jcr:primaryType="nt:unstructured">
<linkDialogConfig
jcr:primaryType="nt:unstructured"
height="{Long}316">
<linkAttributes jcr:primaryType="cq:WidgetCollection">
<linkAdvanced/>
</linkAttributes>
</linkDialogConfig>
</links>
<misctools
jcr:primaryType="nt:unstructured"
features="*"/>
<edit
jcr:primaryType="nt:unstructured"
features="*"/>
<findreplace
jcr:primaryType="nt:unstructured"
features="*"/>
<format
jcr:primaryType="nt:unstructured"
features="*"/>
<image
jcr:primaryType="nt:unstructured"
features="*"/>
<undo
jcr:primaryType="nt:unstructured"
features="*"/>
<table
jcr:primaryType="nt:unstructured"
features="*"/>
<subsuperscript
jcr:primaryType="nt:unstructured"
features="*"/>
<spellcheck
jcr:primaryType="nt:unstructured"
features="*"/>
<lists
jcr:primaryType="nt:unstructured"
features="*"/>
<justify
jcr:primaryType="nt:unstructured"
features="*"/>
<keys
jcr:primaryType="nt:unstructured"
features="*"/>
<paraformat
jcr:primaryType="nt:unstructured"
features="*"/>
<styles
jcr:primaryType="nt:unstructured"
features="*">
<styles jcr:primaryType="nt:unstructured">
<red
jcr:primaryType="nt:unstructured"
cssName="red"
text="Red text"/>
<bold
jcr:primaryType="nt:unstructured"
cssName="bold"
text="Bold text"/>
</styles>
</styles>
</rtePlugins>
</description>
<installationdocmtlink
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
composite="{Boolean}true"
fieldLabel="installationdocmtlink"
name="./installationdocmtlink">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
name="./products">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<Installationdocumentlink
jcr:primaryType="nt:unstructured"
sling:resourceType="cq/gui/components/coral/common/form/pagefield"
fieldDescription="Installationdocument Link"
fieldLabel="Installationdocument Link"
name="./installationdocumentlink"
rootPath="/content"/>
</items>
</column>
</items>
</field>
</installationdocmtlink>
</items>
</column>
</items>
</content>
</jcr:root>

 

********************My HTL is below***********************

<h1> Installation Documents </h1>
<div class="installation-documents" data-sly-use.installationdocuments="com.sunita.core.components.models.InstallationDocumentModel">

<h2 class="installation_header">${installationdocuments.header}</h2>
</br>
<h3>${installationdocuments.description}</h3>

<div data-sly-list.link="${installationdocuments.installationdocmtlink.listChildren}">
<p><b>Dscription:</b> ${link.installationdocumentlink}</p>
</div>

</div>

****************My Sling Model Java Class*********************

package com.sunita.core.components.internal.models.v1;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Via;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;

import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;
import com.sunita.core.components.models.InstallationDocumentModel;

@Model(adaptables = SlingHttpServletRequest.class, adapters = {InstallationDocumentModel.class,
ComponentExporter.class}, resourceType = InstallationDocumentImpl.RESOURCE_TYPE, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@3484101(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class InstallationDocumentImpl implements InstallationDocumentModel {
static final String RESOURCE_TYPE = "sunita/components/installation/v1/installation";

@ValueMapValue
@2434638("resource")
private String header;

@ValueMapValue
@2434638("resource")
private String description;

@ValueMapValue
@2434638("resource")
private String installationdocmtlink;

public static String getResourceType() {
return RESOURCE_TYPE;
}

@9944223
public String getHeader() {
return header;
}

@9944223
public String getDescription() {
return description;
}

@9944223
public String getInstallationdocmtlink() {
return installationdocmtlink;
}

@9944223
public String getExportedType() {
return RESOURCE_TYPE;
}

}

Can anybody please let me know if I am doing any wrong / missing anything ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Nupur_Jain

Hi @dipu2 

 

Eveything looks fine except the placement of the name property in the multifield in your dialog. When we use composite multifield, the name property with which the resource created under component resource is not given in name property of the multifield node but on the "field" node of the dialog.

 

With you structure, the items must be saving under "products" child node. 

 

The property with "name="./installationdocmtlink" should be present on the field node like this:

installationdocmtlink
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
composite="{Boolean}true"
fieldLabel="installationdocmtlink">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
name="./installationdocmtlink">
<items jcr:primaryType="nt:unstructured">

 

After this change, save dialog and test again. Your code should work.

 

Hope it helps!

Thanks!

Nupur

7 replies

vanegi
Adobe Employee
Adobe Employee
July 27, 2020

Can you try adding the composite="{Boolean}true" property to the multifield? A composite multilfield can handle multiple fields within a field set.

Sharing as an example:

<states
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/multifield"
    class="full-width"
    fieldDescription="Click '+' to add a new page"
    fieldLabel="Sites"
    composite="{Boolean}true">

This post [0] explains well!

 

 

Consider the following dialog XML:

<?xml version="1.0" encoding="UTF-8"?>
jcr:primaryType="nt:unstructured"
jcr:title="Companies"
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">
<companies
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
fieldDescription="Click 'Add Field' to add a new company."
composite="{Boolean}true">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
name="./companies">
<items jcr:primaryType="nt:unstructured">
<name
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldLabel="Comp. Name"
name="name"/>
<departments
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
fieldDescription="Click 'Add Field' to add a new department."
fieldLabel="Departments"
composite="{Boolean}true">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
name="./departments">
<items jcr:primaryType="nt:unstructured">
<name
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldLabel="Dep. Name"
name="name"/>
<manager
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldLabel="Manager"
name="manager"/>
</items>
</field>
</departments>
</items>
</field>
</companies>
</items>
</column>
</items>
</content>
</jcr:root>

 

[0]: https://blogs.perficient.com/2018/08/24/using-sling-models-with-nested-composite-mulitifields-in-aem-6-3/

dipu2Author
Level 3
July 27, 2020

Hi ,

 

I have already added composite="{Boolean}true" , as shown in below

 

<installationdocmtlink
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
composite="{Boolean}true"
fieldLabel="installationdocmtlink"
name="./installationdocmtlink">

Suraj_Kamdi
Community Advisor
Community Advisor
July 27, 2020

@dipu2 

Use @ChildResource Annotation to get all the multifield values using sightly.

Example: 

@ChildResource

private List<Resource>installationdocmtlink;

 

Documentation: 

https://sling.apache.org/documentation/bundles/models.html 

 

Please let me know if you need any help with this.

Nupur_Jain
Adobe Employee
Nupur_JainAdobe EmployeeAccepted solution
Adobe Employee
July 27, 2020

Hi @dipu2 

 

Eveything looks fine except the placement of the name property in the multifield in your dialog. When we use composite multifield, the name property with which the resource created under component resource is not given in name property of the multifield node but on the "field" node of the dialog.

 

With you structure, the items must be saving under "products" child node. 

 

The property with "name="./installationdocmtlink" should be present on the field node like this:

installationdocmtlink
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
composite="{Boolean}true"
fieldLabel="installationdocmtlink">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
name="./installationdocmtlink">
<items jcr:primaryType="nt:unstructured">

 

After this change, save dialog and test again. Your code should work.

 

Hope it helps!

Thanks!

Nupur

dipu2Author
Level 3
July 27, 2020

Hi Nupur and All,

 

After I changed in field , also value is not coming in my page.

 

**************My dialog content.xml after changing************

<?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="Have Questions"
sling:resourceType="cq/gui/components/authoring/dialog">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<header
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="Installation Label"
fieldLabel="Installation Header"
name="./header"/>
<installationdocmtlink
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
composite="{Boolean}true"
fieldLabel="installationdocmtlink">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
name="./installationdocmtlink">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<Installationdocumentlink
jcr:primaryType="nt:unstructured"
sling:resourceType="cq/gui/components/coral/common/form/pagefield"
fieldDescription="Installationdocument Link"
fieldLabel="Installationdocument Link"
name="./installationdocumentlink"
rootPath="/content"/>
</items>
</column>
</items>
</field>
</installationdocmtlink>
</items>
</column>
</items>
</content>
</jcr:root>

 

***************************** My HTML page ***********************

<h1> Sunita Installation Documents </h1>
<div class="installation-documents" data-sly-use.installationdocuments="com.sunita.core.components.models.InstallationDocumentModel">

<h2 class="installation_header">${installationdocuments.header}</h2>
</br>

<div data-sly-list.link="${installationdocuments.installationdocmtlink.listChildren}">
<p><b>Dscription:</b> ${link.installationdocumentlink}</p>
</div>

</div>

 

********************** My Java classes******************

package com.sunita.core.components.internal.models.v1;

import javax.inject.Inject;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Optional;
import org.apache.sling.models.annotations.Via;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.osgi.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;
import com.sunita.core.components.models.InstallationDocumentModel;

@Model(adaptables = { SlingHttpServletRequest.class, Resource.class }, adapters = { InstallationDocumentModel.class,
ComponentExporter.class }, resourceType = InstallationDocumentImpl.RESOURCE_TYPE, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)

@3484101(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)

public class InstallationDocumentImpl implements InstallationDocumentModel {

static final String RESOURCE_TYPE = "sunita/components/installation/v1/installation";

protected static final Logger LOGGER = LoggerFactory.getLogger(InstallationDocumentImpl.class);

@ValueMapValue
@2434638("resource")
private String header;

// Inject the installationdocmtlink node under the current node

@586265
@7392697
public Resource installationdocmtlink;

/*
* @ChildResource
*
* @2434638("resource") private String installationdocmtlink;
*/

public static String getResourceType() {
return RESOURCE_TYPE;
}

@9944223
public String getHeader() {
LOGGER.info("Before return" + header);
return header;
}

@9944223
public Resource getInstallationdocmtlink() {
LOGGER.info("Before return123" + installationdocmtlink);
return installationdocmtlink;
}

@9944223
public String getExportedType() {
return RESOURCE_TYPE;
}

}

 

****************************Another class ********************

package com.sunita.core.components.models;

import org.osgi.annotation.versioning.ConsumerType;
import org.osgi.resource.Resource;

import com.adobe.cq.export.json.ComponentExporter;

@ConsumerType
public interface InstallationDocumentModel extends ComponentExporter {

String getHeader();

Resource getInstallationdocmtlink();

}

 

The issue is here either I put @childresource "or" @7392697 , multifield value is not coming. Am I missing anything in java class ?

Please help me.

 

dipu2Author
Level 3
July 27, 2020

Hi Nupur and All,

 

After I changed in field , also value is not coming in my page.

 

**************My dialog content.xml after changing************

<?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="Have Questions"
sling:resourceType="cq/gui/components/authoring/dialog">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<header
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="Installation Label"
fieldLabel="Installation Header"
name="./header"/>
<installationdocmtlink
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/multifield"
composite="{Boolean}true"
fieldLabel="installationdocmtlink">
<field
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container"
name="./installationdocmtlink">
<items jcr:primaryType="nt:unstructured">
<column
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<Installationdocumentlink
jcr:primaryType="nt:unstructured"
sling:resourceType="cq/gui/components/coral/common/form/pagefield"
fieldDescription="Installationdocument Link"
fieldLabel="Installationdocument Link"
name="./installationdocumentlink"
rootPath="/content"/>
</items>
</column>
</items>
</field>
</installationdocmtlink>
</items>
</column>
</items>
</content>
</jcr:root>

 

***************************** My HTML page ***********************

<h1> Sunita Installation Documents </h1>
<div class="installation-documents" data-sly-use.installationdocuments="com.sunita.core.components.models.InstallationDocumentModel">

<h2 class="installation_header">${installationdocuments.header}</h2>
</br>

<div data-sly-list.link="${installationdocuments.installationdocmtlink.listChildren}">
<p><b>Dscription:</b> ${link.installationdocumentlink}</p>
</div>

</div>

 

********************** My Java classes******************

package com.sunita.core.components.internal.models.v1;

import javax.inject.Inject;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Optional;
import org.apache.sling.models.annotations.Via;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.osgi.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;
import com.sunita.core.components.models.InstallationDocumentModel;

@Model(adaptables = { SlingHttpServletRequest.class, Resource.class }, adapters = { InstallationDocumentModel.class,
ComponentExporter.class }, resourceType = InstallationDocumentImpl.RESOURCE_TYPE, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)

@exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)

public class InstallationDocumentImpl implements InstallationDocumentModel {

static final String RESOURCE_TYPE = "sunita/components/installation/v1/installation";

protected static final Logger LOGGER = LoggerFactory.getLogger(InstallationDocumentImpl.class);

@ValueMapValue
@Via("resource")
private String header;

// Inject the installationdocmtlink node under the current node

@inject
@Optional
public Resource installationdocmtlink;

/*
* @ChildResource
*
* @Via("resource") private String installationdocmtlink;
*/

public static String getResourceType() {
return RESOURCE_TYPE;
}

@Override
public String getHeader() {
LOGGER.info("Before return" + header);
return header;
}

@Override
public Resource getInstallationdocmtlink() {
LOGGER.info("Before return123" + installationdocmtlink);
return installationdocmtlink;
}

@Override
public String getExportedType() {
return RESOURCE_TYPE;
}

}

 

****************************Another class ********************

package com.sunita.core.components.models;

import org.osgi.annotation.versioning.ConsumerType;
import org.osgi.resource.Resource;

import com.adobe.cq.export.json.ComponentExporter;

@ConsumerType
public interface InstallationDocumentModel extends ComponentExporter {

String getHeader();

Resource getInstallationdocmtlink();

}

 

The issue is here either I put @childresource "or" @Optional , multifield value is not coming. Am I missing anything in java class ?

Please help me.

 

Vijayalakshmi_S
Level 10
July 27, 2020

Hi @dipu2,

In the Model class originally shared in post has the adaptables -> SlingHttpServletRequest.class alone. 

In the second trial it has both request and resource.

Either ways, below will work. 

 

@ChildResource private Resource outerMulti; // multifield -> field node -> name atribute public Resource getOuterMulti() { // respective getter return outerMulti; }

 

Explanation :

With respect to the component resource that is adapted to the Model (that we write), multifield node is a child resource/node.

Hence we need to use this annotation(@ChildResource) with type as "Resource".

In the HTL, now the getter exposed is of type "Resource" and hence listChildren on the same would work.

(I assumed that you have tried this annotation with String data type and @Via("resource") per the commented code)

@Via is needed only when the object other than original adaptable is needed. You can even try removing @Via("resource") in "header" dialog field. It should still work. 

Please update this thread if you still face any issues. 

Note :

Given the available list of annotations(considering the adaptables), we have few other ways of retrieving values authored via multifield component. With the code shared, we can use this as an option. Will try to cover other possibilities in some time. 

dipu2Author
Level 3
July 28, 2020

Hi Vijaya,

 

I tried by putting below code in model , as suggested by you.

 

protected static final Logger LOGGER = LoggerFactory.getLogger(InstallationDocumentImpl.class);

@ValueMapValue
@2434638("resource")
private String header;

// Inject the installationdocmtlink node under the current node

/*
* @586265
*
* @7392697 public Resource installationdocmtlink;
*/


@ChildResource
private Resource installationdocmtlink;

public static String getResourceType() {
return RESOURCE_TYPE;
}

@9944223
public String getHeader() {
LOGGER.info("Before return header *******" + header);
return header;
}

@9944223
public Resource getInstallationdocmtlink() {
LOGGER.info("Before return12345" + installationdocmtlink);
return installationdocmtlink;
}

@9944223
public String getExportedType() {
return RESOURCE_TYPE;
}

}

 

But still it is not working and in my logfile , I am getting below null for multifield.

 

2020-07-28 06:38:09.962 INFO [com.sunita.core.components.internal.models.v1.InstallationDocumentImpl] Before return header *******installation
2020-07-28 06:38:09.962 INFO [com.sunita.core.components.internal.models.v1.InstallationDocumentImpl] Before return header *******installation
2020-07-28 06:38:09.962 INFO [com.sunita.core.components.internal.models.v1.InstallationDocumentImpl] Before return12345null
2020-07-28 06:38:09.962 INFO [com.sunita.core.components.internal.models.v1.InstallationDocumentImpl] Before return12345null

 

 

dipu2Author
Level 3
July 28, 2020

Hi Vijaya and All,

 

Hi Vijaya,

 

I tried by putting below code in model , as suggested by you.

 

protected static final Logger LOGGER = LoggerFactory.getLogger(InstallationDocumentImpl.class);

@ValueMapValue
@2434638("resource")
private String header;

// Inject the installationdocmtlink node under the current node

/*
* @586265
*
* @7392697 public Resource installationdocmtlink;
*/


@ChildResource
private Resource installationdocmtlink;

public static String getResourceType() {
return RESOURCE_TYPE;
}

@9944223
public String getHeader() {
LOGGER.info("Before return header *******" + header);
return header;
}

@9944223
public Resource getInstallationdocmtlink() {
LOGGER.info("Before return12345" + installationdocmtlink);
return installationdocmtlink;
}

@9944223
public String getExportedType() {
return RESOURCE_TYPE;
}

}

 

But still it is not working and in my logfile , I am getting below null for multifield.

 

2020-07-28 06:38:09.962 INFO [com.sunita.core.components.internal.models.v1.InstallationDocumentImpl] Before return header *******installation
2020-07-28 06:38:09.962 INFO [com.sunita.core.components.internal.models.v1.InstallationDocumentImpl] Before return header *******installation
2020-07-28 06:38:09.962 INFO [com.sunita.core.components.internal.models.v1.InstallationDocumentImpl] Before return12345null
2020-07-28 06:38:09.962 INFO [com.sunita.core.components.internal.models.v1.InstallationDocumentImpl] Before return12345null

 

Soon I am posting my whole package in github and share the link with you.

dipu2Author
Level 3
July 28, 2020

Dear Vijaya and All,

 

I tried by putting below code in model , as suggested by you.

 

protected static final Logger LOGGER = LoggerFactory.getLogger(InstallationDocumentImpl.class);

@ValueMapValue
@Via("resource")
private String header;

// Inject the installationdocmtlink node under the current node

/*
* @inject
*
* @Optional public Resource installationdocmtlink;
*/


@ChildResource
private Resource installationdocmtlink;

public static String getResourceType() {
return RESOURCE_TYPE;
}

@Override
public String getHeader() {
LOGGER.info("Before return header *******" + header);
return header;
}

@Override
public Resource getInstallationdocmtlink() {
LOGGER.info("Before return12345" + installationdocmtlink);
return installationdocmtlink;
}

@Override
public String getExportedType() {
return RESOURCE_TYPE;
}

}

 

But still it is not working and in my logfile , I am getting below null for multifield.

 

2020-07-28 06:38:09.962 INFO [com.sunita.core.components.internal.models.v1.InstallationDocumentImpl] Before return header *******installation
2020-07-28 06:38:09.962 INFO [com.sunita.core.components.internal.models.v1.InstallationDocumentImpl] Before return header *******installation
2020-07-28 06:38:09.962 INFO [com.sunita.core.components.internal.models.v1.InstallationDocumentImpl] Before return12345null
2020-07-28 06:38:09.962 INFO [com.sunita.core.components.internal.models.v1.InstallationDocumentImpl] Before return12345null

 

Please find my component and java files. NOTE that now I am focusing more on the getting dialog multi field values in slingmodel through logger rather than HTML.

https://github.com/sunita197881/sunitaworkplace/tree/multifieldissue

It is stopping me for releasing sprint. Please help me.