You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Hans-Peter Stoerr (JIRA)" <ji...@apache.org> on 2017/09/13 07:55:00 UTC

[jira] [Commented] (SLING-5726) Allow ValueMapInjector and ResourcePathInjector to act directly on SlingHttpServletRequest

    [ https://issues.apache.org/jira/browse/SLING-5726?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16164269#comment-16164269 ] 

Hans-Peter Stoerr commented on SLING-5726:
------------------------------------------

I'd like to support this, and suggest a little extension. I would like to see ResourcePathInjector (and ChildResourceInjector) work on anything that can {{adaptTo}} a Resource or Request.

Background: for constructing the models we use our own container which, among other things, has the request, the response, the resolver and a resource, as a basis, since all of these things are sometimes needed. It can adaptTo the Request or Resource, but to use @ResourcePath we currently have to add an annoying @Via("request").

That can be done nicely by adding an "Adaptable" branch in AbstractInjector#getResourceResolver , as there is in AbstractInjector#getValueMap.

> Allow ValueMapInjector and ResourcePathInjector to act directly on SlingHttpServletRequest
> ------------------------------------------------------------------------------------------
>
>                 Key: SLING-5726
>                 URL: https://issues.apache.org/jira/browse/SLING-5726
>             Project: Sling
>          Issue Type: Bug
>          Components: Extensions
>    Affects Versions: Sling Models Impl 1.2.8
>            Reporter: Konrad Windszus
>            Assignee: Konrad Windszus
>         Attachments: SLING-5726.patch
>
>
> Currently both injectors only work correctly on objects being adaptable to a {{ValueMap}}. For {{ValueMapInjector}} this is documented but for {{ResourcePathInjector}} it is not (http://sling.apache.org/documentation/bundles/models.html#available-injectors), although for the latter it does only matter if the path is given through a resource property and not in a static way.
> This should be relaxed that both also work with {{SlingHttpServletRequest}} as that always carries the current resource from which the {{ValueMap}} can be easily retrieved.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)