Sling Model and Sightly

Avatar

Avatar

ad6

Avatar

ad6

ad6

15-10-2015

I have a Sling Model class and i want to use it in sightly.

My Sling model should be map to the JCR node in order to access the node properties.

So how to map sightly with Sling Model and JCR node?

View Entire Topic

Avatar

Avatar

ad6

Avatar

ad6

ad6

15-10-2015

thanks for your reply.

I have a following Sling Model class :

package com;

import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Optional;

import javax.inject.Inject;
import javax.inject.Named;


@Model(adaptables=Resource.class)
public class Phone {
    @Inject
    @Optional
    public String defaultColour;
    @Inject
    @Optional
    public String modelName;
  
    public String getDefaultColour() {
        return defaultColour;
    }
    public void setDefaultColour(String defaultColour) {
        this.defaultColour = defaultColour;
    }
    public String getModelName() {
        return modelName;
    }
    public void setModelName(String modelName) {
        this.modelName = modelName;
    }
   }

 

THis is the path of resource which i need to adapt in sling model:

/etc/product/phone/apple

Follwoing is the sightly code :

<div data-sly-use.geocode="com.Phone">

<div> <img src ='${phone.defaultColour}' title ="Logo Image" style="float:left;width:196px;"/> </div>
</div>

 

in this ${phone.defaultColour} is coming as empty.

So how to map my sling model class the the resource path using sightly.