Hello Everyone,
I have a multifield which stores data in node structure. I am using sling models to read it. When i drag and drop the component,I get following error
"org.apache.sling.scripting.sightly.SightlyException: Identifier com.test.core.models.WCMUsejsDemo cannot be correctly instantiated by the Use API".
After page refresh there is no error.
Multifield is stored as shown below:
Code of WCMUsejsDemo:
import javax.inject.Inject;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
@Model(adaptables=Resource.class)
public class WCMUsejsDemo {
@Inject
public Resource userstory;
}
Thanks,
Megha Gowroji
Solved! Go to Solution.
Views
Replies
Total Likes
Best way in AEM 6.3 to use Multifield is to use the Granite/Coral MF type and Sling Models- as discussed here:
Notice the use of Sling Models and HLT to read the MF in this example.
Then you can easily render out the MF values to the web page - such as:
Views
Replies
Total Likes
Here you go:- Creating an AEM HTML Template Language 6.3 component that uses a Multifield
and from Coral3:- Creating a Granite/Coral 6.3 Multifield HTL component for Adobe Experience Manager
Views
Replies
Total Likes
You should try using the @ChildResource annotation instead of @Inject
Views
Replies
Total Likes
Yes using @ChildResource you can get multifield value
@ChildResource(injectionStrategy = InjectionStrategy.OPTIONAL)
private Resource multinodes;
Once you get the childResource, iterate through all the child nodes
Iterator<Resource> iterator = multinodes.listChildren();
Best way in AEM 6.3 to use Multifield is to use the Granite/Coral MF type and Sling Models- as discussed here:
Notice the use of Sling Models and HLT to read the MF in this example.
Then you can easily render out the MF values to the web page - such as:
Views
Replies
Total Likes
Thank you Scott.
Adding @Optional annotation worked for me.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies