Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-3516

Sling Models Resource Child List Injector

    XMLWordPrintableJSON

Details

    Description

      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:

      +- dealer
        |
        +- addresses
           |
           + -address1
           |
           +- address2
      

      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:

      @Inject
      List<AddressModel> addresses
      

      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.

      Attachments

        Activity

          People

            justinedelson Justin Edelson
            isechyn Igor Sechyn
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: