[
https://issues.apache.org/jira/browse/SLING-7015?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Justin Edelson updated SLING-7015:
----------------------------------
Fix Version/s: Sling Models Impl 1.4.4
Sling Models API 1.3.6
> Add Utility Method to ModelFactory to help proper model creation from child
> resources in a request context
> ----------------------------------------------------------------------------------------------------------
>
> Key: SLING-7015
> URL: https://issues.apache.org/jira/browse/SLING-7015
> Project: Sling
> Issue Type: Improvement
> Components: Extensions
> Reporter: Justin Edelson
> Fix For: Sling Models Impl 1.4.4, Sling Models API 1.3.6
>
> Attachments: SLING-7015.diff
>
>
> At present, it is somewhat complex to generate Sling Model objects (or
> really, any adapter class) from an included resource. This is especially true
> when the adaptable is the SlingHttpServletRequest object.
> There are a few different cases which are problematic:
> 1. When you want to inject an object adapted from a child resource where the
> adaptable is a request object (i.e. you want to override the
> request.getResource() to the child resource)
> 2. When you want to inject an object adapted from a child resource
> (regardless of the adaptable) and the model class depends upon the Script
> Bindings.
> In the first case, this currently requires creating a wrapper request. The
> second case is more complex to solve as (to do it correctly) requires
> re-invoking all of the BindingsValuesProviders (which entails creating a fake
> ScriptEngine).
> To solve both issues, I would like to add a new method named
> {{getModelFromWrappedRequest}}. Parameters would be
> {{SlingHttpServletRequest}}, {{Resource}}, {{Class}}.
> This method would create a wrapped request with the passed resource, set the
> bindings to a new object and reinvoke the BVPs.
> Patch to follow, but I wanted to file this early to get any feedback.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)