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 2014/06/17 22:03:03 UTC

[jira] [Resolved] (SLING-3516) Sling Models Resource Child List Injector

     [ https://issues.apache.org/jira/browse/SLING-3516?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Justin Edelson resolved SLING-3516.
-----------------------------------

    Resolution: Fixed

I have committed a modified version of the patch in r1603277. The most significant change is that the call to resource.adaptTo() for a list is now done in the ModelAdapterFactory rather than in the ChildResourceInjector. The reason for this is that this is where the existing adaptTo() call is made, so it seemed to make more sense to co-locate them. 

Thanks Igor!

> Sling Models Resource Child List Injector
> -----------------------------------------
>
>                 Key: SLING-3516
>                 URL: https://issues.apache.org/jira/browse/SLING-3516
>             Project: Sling
>          Issue Type: New Feature
>          Components: Extensions
>    Affects Versions: Sling Models Implementation 1.0.2
>            Reporter: Igor Sechyn
>            Assignee: Justin Edelson
>            Priority: Minor
>             Fix For: Sling Models Implementation 1.0.6
>
>         Attachments: ChildResourceInjectorPatch.diff
>
>
> Hi All,
> We have decided to use the sling models to process some hierarchical data in our project and are facing the following issue right now.
> Our content structure looks as follows:
> {code}
> +- dealer
>   |
>   +- addresses
>      |
>      + -address1
>      |
>      +- address2
> {code}
> Dealer and address nodes have attributes, that can be injected through the ValueMapInjector, so everything works fine here. Our goal however is also to inject the List of AddressModel objects into the DealerModel object, something like this:
> {code}
> @Inject
> List<AddressModel> addresses
> {code}
> The desired behavior would be:
> - the injector resolves addresses as a child resource of the adaptable object
> - iterates over the children of this resource (in this case „addresses")
> - adapts each child to the actual type argument of the parameterized list type
> - returns the list of adapted model objects
> I have tried to play around with @Named but could not get it to work. The only way of making it work, was to write a custom injector, which worked out pretty fine. 
> But I was still wondering, if there might be an OOTB functionality, which can be used for this use case
> Cheers, Igor.



--
This message was sent by Atlassian JIRA
(v6.2#6252)