大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
本篇内容介绍了“Sling model的作用是什么”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
站在用户的角度思考问题,与客户深入沟通,找到海安网站设计与海安网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站设计、网站制作、企业官网、英文网站、手机端网站、网站推广、空间域名、网页空间、企业邮箱。业务覆盖海安地区。
Internal object:
import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.models.annotations.Model; import org.apache.sling.models.annotations.injectorspecific.SlingObject; @Model( adaptables = {Resource.class}) public class AbstractModelResource { @SlingObject ResourceResolver resolver; @SlingObject Resource resource; }
real fields:
@Model(adaptables=Resource.class,defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL) public class JobDetailModel extends AbstractModel{ @OSGiService JobTriggerService jobTriggerService; private JobEntity job; private String appUrl; private String postingDate; private String postingDateFormat; @Inject @Optional @Named("subTitle") @Default(values="") private String subTitle; @Inject @Optional @Named("qualifications") @Default(values="") private String qualifications; @Inject @Optional @Named("jobID") @Default(values="") private String jobID; @Inject @Optional @Named("jobFunction") @Default(values="") private String jobFunction; @Inject @Optional @Named("postingDateLabel") @Default(values="") private String postingDateLabel; @Inject @Optional @Named("applyBtn") @Default(values="") private String applyBtn; @Inject @Optional @Named("scheduleLabel") @Default(values="") private String scheduleLabel; @Inject @Optional @Named("jobDetailsText") @Default(values="") private String jobDetailsText; @Inject @Optional @Named("relJobsText") @Default(values="") private String relJobsText; @Inject @Optional @Named("Job") private JobModel jobModel; @PostConstruct protected void init() { } }
Job Model:
import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Default; import org.apache.sling.models.annotations.Model; import org.apache.sling.models.annotations.Optional; import javax.inject.Inject; import javax.inject.Named; import java.util.List; @Model(adaptables = Resource.class) public class JobModel { @Inject @Optional@Named("BrandName") @Default(values="") private String BrandName; @Inject @Optional @Named("PrimaryLocation") PrimaryLocation primaryLocation; @Inject @Optional @Named("Postings") Listpostings; @Inject @Optional @Named("JobField") JobField JobField; @Model(adaptables = Resource.class) public static class PrimaryLocation{ @Inject @Optional @Named("Country") @Default(values="") String Country; @Inject @Optional @Named("State") @Default(values="") String State; } }
for request:
@Model(
adaptables = {Resource.class, SlingHttpServletRequest.class},
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public abstract class AbstractModel extends AbstractModelResource{
@SlingObject
ResourceResolver resolver;
@Inject
@Via("resource")
Resource resource;
@Inject
@Via("request")
SlingHttpServletRequest request;
@OSGiService
}
“Sling model的作用是什么”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!