cq5 - How to instantiate a Sling Model with multiple adaptables -
the @model
annotation in sling models allows multiple adaptables, example @model(adaptables = { slinghttpservletrequest.class, resource.class })
however, not sure how instantiate model multiple adaptables jsp. options shown in sling documentation specify single adaptable only: https://sling.apache.org/documentation/bundles/models.html#adaptto
when model adaptable both classes means can use of them, not have adapt both.
so, adapt other sling model. should work both. in case
<sling:adaptto adaptable="${resource}" adaptto="org.apache.sling.models.it.models.mymodel" var="model"/>
or
<sling:adaptto adaptable="${slingrequest}" adaptto="org.apache.sling.models.it.models.mymodel" var="model"/>
still, remember if using injection, not injectors available both adaptables. request supports more resource (anything comes script bindings, currentpage,etc)
Comments
Post a Comment