AEM Sling Model Class

    0

    8

    placidmasvidal

    aemsling

    The class filename has the following Model:

    @Model(adaptables = {Resource.class, SlingHttpServletRequest.class}, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL) public class filename {

    The filename class has the following two @SlingObject properties:

    private ResourceResolver resourceResolver;

    private SlingHttpServletRequest request;

    The init() method is called when the class is created. In this method, the following code is executed:

    @SlingObject private ResourceResolver resourceResolver; @SlingObject private SlingHttpServletRequest request;

    The init() method also sets the default injection strategy to be OPTIONAL.

    Library: AEM

    Shortcut: createmodel

    Filename pattern: *.java

    import org.apache.sling.models.annotations.DefaultInjectionStrategy;
    import org.apache.sling.models.annotations.injectorspecific.SlingObject;
    import org.apache.sling.api.resource.ResourceResolver;
    import org.apache.sling.api.resource.Resource;
    import org.apache.sling.api.SlingHttpServletRequest;
    import org.apache.sling.models.annotations.Model;
    import javax.annotation.PostConstruct;
    
    @Model(adaptables = {Resource.class, SlingHttpServletRequest.class},
        defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
    public class filename {
    
      @SlingObject
      private ResourceResolver resourceResolver;
      @SlingObject
      private SlingHttpServletRequest request;
    
      @PostConstruct
      protected void init() {
    
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.