我试图使用AEM 6.3中的Sling模型来获取页面属性,但总是得不到任何结果。
resultsRootPath = getCurrentPage().getProperties().get("ResultsRootPath", String.class);属性路径:
/components/content/results/cq:dialog/content/items/column/items/ResultsRootPath你能让我知道用吊索模型计算房产价值的正确方法吗?
发布于 2018-09-08 16:04:41
您还可以执行以下操作:
@Model(adaptables = {SlingHttpServletRequest.class,Resource.class})
public class MyCustomModel{
@Inject
private InheritanceValueMap pageProperties;
@Inject
private ValueMap properties;
@PostConstruct
public void activate() {
String pageString = pageProperties.getInherited("myproperty", "default"); //InheritanceValueMap gives pageProperties Value Map and getInherited is used to fetch a particular property.
}有关更多信息,请参阅:http://blogs.adobe.com/experiencedelivers/experience-management/valuemap-and-his-friend/
发布于 2018-03-26 18:44:01
在您的模型类中,您可以创建如下字段:
@Model(adaptables = Page.class)
public class ResultsPageModel {
@Inject
@Via("contentResource")
@Named("ResultsRootPath")
private Resource resultsRootPath;
}发布于 2019-03-27 23:49:30
要利用injector specific annotation,更好的方法是:
@Model(adaptables = SlingHttpServletRequest.class)
public class MyModel {
@ValueMapValue
private String ResultsRootPath;
public String getResultsRootPath(){ return ResultsRootPath; }
}值得一提的是,请在resultsRootPath中对属性使用驼峰式大小写。
https://stackoverflow.com/questions/48079450
复制相似问题