Replies

Avatar

Avatar

Feike_Visser1

Employee

Avatar

Feike_Visser1

Employee

Feike_Visser1
Employee

04-10-2016

Here my sample:

package adobe.summit.lasvegas.core;

 

import java.util.LinkedList;

import java.util.List;

 

import com.adobe.cq.sightly.WCMUsePojo;

 

public class MiniNav extends WCMUsePojo {

 

    private List<MiniNavBean> navList = new LinkedList<MiniNavBean>();

 

    MiniNavBean miniNav;

 

    public List<MiniNavBean> getNavList() {

        return navList;

    }

 

    public void setNavList(List<MiniNavBean> navList) {

        this.navList = navList;

    }

 

@Override

    public void activate() {

 

        miniNav = new MiniNavBean("fpaths", "activeattrs");

 

        navList.add(miniNav);

 

    }

 

}

 

HTL:

<div data-sly-use.mininav="adobe.summit.lasvegas.core.MiniNav" data-sly-list.navlist="${mininav.navList}">
                <li>
                <p>${navlist.activeattr}</p>
                </li>

</div>

Avatar

Avatar

rohitn62196663

Avatar

rohitn62196663

rohitn62196663

04-10-2016

My code is similar to yours, but wondering why is it not working on my end:
 

Code sample:

 

public class MiniNav extends WCMUsePojo {


    private List<MiniNavBean> navList;
    
    
    public List<MiniNavBean> getNavList() {
        return navList;
    }


    public void setNavList(List<MiniNavBean> navList) {
        this.navList = navList;
    }


    @Override
    public void activate() {
        
        navList = new LinkedList<MiniNavBean>();
        MiniNavBean miniNavObj = new MiniNavBean("fpath", "activeattr", "scptitle");
        navList.add(miniNavObj);
        
    }

}

 

Sighly:

<div data-sly-include="/apps/<application>/components/global.jsp"></div>
<div data-sly-use.mininav="com.xxx.totalinsight.components.MiniNav" data-sly-list.navlist="${mininav.navList}" data-sly-unwrap>
    <div class="content center">
        <div class="itemsList">
            <ul>
                <li>
                    <p>fpath : ${navlist.fPath}</p>
                    <p>activeAttr: ${navlist.activeAttr}</p>
                </li>
            </ul>
        </div>
    </div>
</div>

Avatar

Avatar

Feike_Visser1

Employee

Avatar

Feike_Visser1

Employee

Feike_Visser1
Employee

04-10-2016

Can you share your bean too?

Avatar

Avatar

rohitn62196663

Avatar

rohitn62196663

rohitn62196663

04-10-2016

package com.xxx.totalinsight.components;

public class MiniNavBean {

    private String fPath;
    
    private String activeAttr;
    
    private String scpTitle;
    
    public MiniNavBean(String fPath, String activeAttr,  String scpTitle){
        
        this.fPath = fPath;
        this.activeAttr = activeAttr;
        this.scpTitle = scpTitle;
    }
    public String getFpath() {
        return fPath;
    }

    public void setFpath(String fpath) {
        this.fPath = fpath;
    }

    public String getActiveattr() {
        return activeAttr;
    }

    public void setActiveattr(String activeattr) {
        this.activeAttr = activeattr;
    }

    public String getScptitle() {
        return scpTitle;
    }

    public void setScptitle(String scptitle) {
        this.scpTitle = scptitle;
    }
    

}

Avatar

Avatar

Feike_Visser1

Employee

Avatar

Feike_Visser1

Employee

Feike_Visser1
Employee

04-10-2016

Looking at your bean on your HTL expressions, they don't match...

you have .fPath and activeAttr

and you have getFpath() and getActiveattr()

 

 <p>fpath : ${navlist.fPath}</p>
 <p>activeAttr: ${navlist.activeAttr}</p>

Avatar

Avatar

Feike_Visser1

Employee

Avatar

Feike_Visser1

Employee

Feike_Visser1
Employee

05-10-2016

Avatar

Avatar

rohitn62196663

Avatar

rohitn62196663

rohitn62196663

05-10-2016

Thanks a lot. It worked now. I was expecting it to work with the variable name itself,didnt know we need to call the getter too in sightly. To refer the linkedlist in sightly I didn't call any getter but I just called the navList object directly as "${mininav.navList}">. But dont know why do we need to call the getter for the variables in bean. 
     
Thanksa lot. It worked now. I was expecting it to work with the variable name itself,didnt know we need to call the getter in sightly. To refer the linkedlist in sightly I didn't call any getter but I just called the navList object directly. But dont know why do we need to call the getter for the variables in bean.