You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Justin Edelson (JIRA)" <ji...@apache.org> on 2017/07/17 16:43:00 UTC
[jira] [Created] (SLING-7015) Add Utility Method to ModelFactory to
help proper model creation from child resources in a request context
Justin Edelson created SLING-7015:
-------------------------------------
Summary: 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
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)