Last active
June 10, 2017 11:06
-
-
Save sgaem/19d38af883877cbd77551b80103f8ffd to your computer and use it in GitHub Desktop.
This is the TestComponentModel.java, which can be used as sling Model Exporters.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mycompany.myproject.sling.models; | |
import org.apache.sling.api.resource.Resource; | |
import org.apache.sling.models.annotations.DefaultInjectionStrategy; | |
import org.apache.sling.models.annotations.Exporter; | |
import org.apache.sling.models.annotations.ExporterOption; | |
import org.apache.sling.models.annotations.Model; | |
import javax.inject.Inject; | |
import javax.inject.Named; | |
@Model(adaptables = Resource.class, resourceType = { "weretail/components/content/heroimage" }, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL) | |
@Exporter(name = "jackson", extensions = "json", options = { @ExporterOption(name = "SerializationFeature.WRITE_DATES_AS_TIMESTAMPS", value = "true") }) | |
public class ModelComponent { | |
@Inject | |
String title; | |
@Inject | |
String heading; | |
@Inject | |
String buttonLabel; | |
@Inject | |
String buttonLinkTo; | |
@Inject | |
String fileReference; | |
@Inject | |
@Named("sling:resourceType") | |
String slingResourceType; | |
public String getHeading() { | |
return heading; | |
} | |
public String getButtonLabel() { | |
return buttonLabel; | |
} | |
public String getButtonLinkTo() { | |
return buttonLinkTo; | |
} | |
public String getSlingResourceType() { | |
return slingResourceType; | |
} | |
public String getTitle() { | |
return title; | |
} | |
public String getFileReference() { | |
return fileReference; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment