Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Get cqdialog properties in Model adaptable from SlingHttpServletRequest

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Level 2

ValueMap vm= request.getResource().getValueMap();

View solution in original post

4 Replies

Avatar

Level 10

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.

Avatar

Community Advisor

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



Arun Patidar

Avatar

Correct answer by
Level 2

ValueMap vm= request.getResource().getValueMap();

Avatar

Level 3

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.