Get cqdialog properties in Model adaptable from SlingHttpServletRequest

maynors2427659

21-02-2019

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

Answers (3)

Answers (3)

VasconcelosAqui

21-02-2019

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.

smacdonald2008

21-02-2019

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.