Get cqdialog properties in Model adaptable from SlingHttpServletRequest




    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 {


private SlingHttpServletRequest request;


private Page currentPage;


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?


Answers (3)

Answers (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.



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.