The @Model annotation in Sling Models allows for multiple adaptables, for example
@Model(adaptables = { SlingHttpServletRequest.class, Resource.class })
However, I am not sure how to instantiate a Model with multiple adaptables from a JSP. The options shown in the Sling documentation always specify a single adaptable only: https://sling.apache.org/documentation/bundles/models.html#adaptto
How to instantiate a Sling Model with multiple adaptables
4k Views Asked by raro At
1
There are 1 best solutions below
Related Questions in AEM
- Impose component restriction to a series of parsys-CQ
- Can't install AEM and Sling plugin in eclipse
- Adobe CQ: Copy node from one CQ instance to another using crx/de
- How to include an existing component multiple times
- How to start a clean publishing instance and sync everything including OSGi bundles?
- How to create multi image component with image preview In adobe cq5?
- TouchUI Image disable upload in dialog
- How to add a custom button in rte plugin in aem/cq
- How can single instance of an OSGI factory configuration be read from Java in CQ
- How to stop sling scheduler work if inconsistent situation occures inside the job?
- Get JSP output within Servlet in AEM
- How to adapt a child node in sling model of aem6
- OSGi Component's default configuration value contains escaped backslash
- How to programatically delete revisions of a page in CQ5?
- Blog component doesn't work properly when change the name of page in AEM 6.0
Related Questions in SLING
- Sling 7 JCR SQL Query Fails On Unicode-Value Properties
- Sling Mock is not allowing to get ResourceResolverFactory
- How to stop sling scheduler work if inconsistent situation occures inside the job?
- Apache sling : org.apache.sling.api.resource.PersistenceException: Unable to create node at /var/discovery))
- How to programatically delete revisions of a page in CQ5?
- How to instantiate a Sling Model with multiple adaptables
- How to create a resource mapping node in AEM using sling REST api and curl
- How to get SlingRequest from saxon TransformerFactory
- CQ5 SlingServlet and resourceTypes not working for specific resource paths
- how to set session attribute in cq5
- Is it possible to switch to Sling Selector Script based on page property
- How does Jackrabbit generate jcr:uuid (in AEM)?
- CQ - Check whether the resource object is valid
- Do I need to call both .dispose() (javax.jcr.Binary) and .close() (java.io.InputStream)?
- AEM: using sling error handler: how do I redirect error originating from specific pages to a specific error page only
Related Questions in SLING-MODELS
- How to adapt a child node in sling model of aem6
- How to instantiate a Sling Model with multiple adaptables
- ResourceBundle not working in AEM 6.2
- AEM get parent node from Valuemapvalue filepath in sling model
- AEM Multifield - Modifying values in multifield values
- How to display a json response mapped pojo in sightly
- Pass data to sling model
- Unit test for post sling servlet aem 6.5
- AEM : How to get list of registered sling models using resource type
- Unable to adapt model class into SlingHttpServletRequest
- Sling models vs WCMUSEPOJO
- lombok delegation pattern not returning all methods in model.json(Json Exporter) for Tabs component
- Access AEM component data as JSON within HTL (Sightly)
- How to return current Page and fetch value by using @Via("resource")?
- How to share data between a page and a component in AEM 6.2?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
When your model is adaptable from both classes it means you can use any of them, not that you have to adapt both.
So, you adapt it as any other Sling Model. Just it should work with both. In you case you could do
or
Still, remember that if you are using injection, not all injectors are available from both adaptables. The request supports more than the resource (anything that comes from the script bindings, currentPage,etc)