I am getting the below error:
Can somebody help to resolve the issue, please?
Below code in the FormRadio.java:
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @JeetendrakumarSa ,
Return type should be same or its parent.
OptionItem type should be same com.adobe.cq.wcm.core.components.models.form.OptionItem
cross check your imports in implementation class
seems you are return something.core.models.form.radio.OptionItem instead of com.adobe.cq.wcm.core.components.models.form.OptionItem
Thanks
Hi @JeetendrakumarSa ,
Return type should be same or its parent.
OptionItem type should be same com.adobe.cq.wcm.core.components.models.form.OptionItem
cross check your imports in implementation class
seems you are return something.core.models.form.radio.OptionItem instead of com.adobe.cq.wcm.core.components.models.form.OptionItem
Thanks
Hi @JeetendrakumarSa ,
Delete your OptionItem.java (as not required) or rename in case getting used in somewhere else in your project or explicitly mention the return type like this
@Override
public List<com.adobe.cq.wcm.core.components.models.form.OptionItem> getItems() {
return items;
}
Find below sample code
package com.abc.core.models;
import java.util.List;
import com.adobe.cq.wcm.core.components.models.form.OptionItem;
import com.adobe.cq.wcm.core.components.models.form.Options;
public interface FormRadio extends Options {
String getTitle();
List<OptionItem> getItems();
}
package com.abc.core.models;
import com.adobe.cq.export.json.ComponentExporter;
import com.adobe.cq.export.json.ExporterConstants;
import com.adobe.cq.wcm.core.components.models.form.OptionItem;
import com.adobe.cq.wcm.core.components.models.form.Options;
import com.adobe.cq.wcm.core.components.util.AbstractComponentImpl;
import lombok.experimental.Delegate;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.*;
import org.apache.sling.models.annotations.injectorspecific.ChildResource;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.apache.sling.models.annotations.via.ResourceSuperType;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.util.List;
@Model(adaptables = SlingHttpServletRequest.class, adapters = { FormRadio.class,
ComponentExporter.class }, resourceType = FormRadioImpl.RESOURCE_TYPE, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class FormRadioImpl extends AbstractComponentImpl implements FormRadio {
public static final String RESOURCE_TYPE = "pmi-atomsmolecules/components/core/form/radio";
@Self
@Via(type = ResourceSuperType.class)
@Delegate(excludes = DelegationExclusion.class)
private Options options;
@PostConstruct
public void init() {
this.options = resource.adaptTo(Options.class);
}
@ValueMapValue
private String title;
@ChildResource
private List<OptionItem> items;
@ValueMapValue
@Default(booleanValues = false)
private boolean textIsRich;
public boolean isRichText() {
return textIsRich;
}
@Inject
public FormRadioImpl(SlingHttpServletRequest request) {
this.options = request.adaptTo(Options.class);
}
public Object getFormId() {
return FormUtil.getInheritedFormId(resource);
//return null;
}
@Override
public String getExportedType() {
return FormRadioImpl.RESOURCE_TYPE;
}
@Override
public String getTitle() {
return title != null ? title : options.getTitle();
}
@Override
public List<OptionItem> getItems() {
return items;
}
private interface DelegationExclusion {
String getExportedType();
String getTitle();
}
}
Thanks
I responded to you, can you please check and confirm?
thanks Mukesh for the quick help
Views
Likes
Replies