Get cqdialog properties in Model adaptable from SlingHttpServletRequest | Community
Skip to main content
maynors2427659
New Participant
February 21, 2019
Solved

Get cqdialog properties in Model adaptable from SlingHttpServletRequest

  • February 21, 2019
  • 4 replies
  • 2369 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by maynors2427659

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

4 replies

VasconcelosAqui
New Participant
February 21, 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.

maynors2427659
maynors2427659AuthorAccepted solution
New Participant
February 21, 2019

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

arunpatidar
New Participant
February 21, 2019

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
smacdonald2008
New Participant
February 21, 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.