繁体   English   中英

我无法在AEM中使用吊索模型显示值

[英]I am not able to display values with the help of sling models in AEM

这是我的模型:

package org.aem.ubusina.core.models;

import javax.inject.Inject;

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

@Model(adaptables = Resource.class)
public class PromoModel {


    @Inject
    public String image;

    @Inject
    public String text;

    @Inject
    public String desc;


    public String getImage() {
        return image;
    }

    public String getText() {
        return text;
    }

    public String getDescription() {
        return desc;
    }   

}

这是HTML代码:

这是说明:$ {model.description}

这是标题:$ {model.title}

我还使用<data-sly-use.model =“ org.aem.ubusina.core.models.PromoModel”>在HTML中添加了我的模型

但是,我无法获取值。 请帮忙。

org.apache.sling.models.api

是在使用吊索模型之前需要解决的依赖性

如果我理解正确,您将无法适应。 确保您的名称=模型类中的字符串名称。 例如在您的dialog.xml中

<image name="./testImage" xtype="pathfield" .... />

您的私人模特儿将拥有

@Inject
@Optional //If the field is not required
private String testImage
public getTestImage(){
return this.testImage;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM