Hi,
Is there a way to access the cq dialog properties from a Model like this:
@Model(adaptables = SlingHttpServletRequest.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class MyClass {
@Self
private SlingHttpServletRequest request;
@Inject
private Page currentPage;
@Inject
private ResourceResolver resourceResolver;
And here's the HTL
<sly data-sly-use.model="${'com.edc.edcweb.core.models.MyClass' }" />
Is there a way to access them without sending them as parameter ( <sly data-sly-use.model="${'com.edc.edcweb.core.models.FeaturedEdcThoughtLead' @ items=properties }" /> ) or if i have to send them by parameter how is this done and what type of object should I declare in the model to receive it?
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
ValueMap vm= request.getResource().getValueMap();
Views
Replies
Total Likes
See this article which shows HTL and sling models and how to work with dialog values that an author enters into a component dialog.
Creating a custom Touch UI Grid Component for Adobe Experience Manager
This article will show you how to use a dialog, use those values in a SLing Model and how to render the values in HTL.
Views
Replies
Total Likes
Hi,
You can either adapt as Resource Type too or inject Resource Type to access dialog property in Model.
https://helpx.adobe.com/experience-manager/using/sling_model_adaptation.html
Views
Replies
Total Likes
ValueMap vm= request.getResource().getValueMap();
Views
Replies
Total Likes
I don't know if I understood your question right, but I think you want to get the request from the servlet addapt to a resource and then you can adapt the resource to your model. If the that is the question you could make that:
Resource resource = request.getResource();
Model model = resource.adaptTo(Model.class);
If you resource is compatible with the model everithing is going to work just fine, and you are going to be able to access your model infomation.
Hope I helped in some way.
Views
Replies
Total Likes