Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adding Columns(parsys) based on number field entries in AEM 6.4


Level 3

Hi All,

I am trying to create a component which will add number of columns based on the number selected in the numberfield in dialog. For exm - If I add 3 in the number field it should then generate a layout consisting of three columns with three parsys.

Currently I'm trying to read the number field value and add these values in a list in java. This is the snippet:

if (null != columnProperties) {

numberofcolumns = (Integer) columnProperties.get("numberofcolumns", 1); //number entered from the dialog in numberfield"Number of Columns: " + numberofcolumns);

for (int i = 0; i < numberofcolumns; i++) {"Inside for loop");

ColumncontainerVO columnItemVO1 = new ColumncontainerVO();

//String col = "autocomplete" + String.valueOf(i + 1);

columnItemVO1.setNumber(i);"Column Item"+columnItemVO1);


}"Outside for loop");


public List<ColumncontainerVO> getcolumnList() {  //list being generated for the entries

return columnList;


After this I'm trying to access this list in sightly using the below code:

<div data-sly-test="${wcmmode.edit}" class="col-content" style="color: gray;">Edit Column Container</br></div>

<div data-sly-use.colControl="com.aem.common.components.mysample.Columncontrol" data-sly-unwrap>

     <div class="sample-container">

         <div class="row class">

           <div data-sly-list="${colControl.columnList}" data-sly-unwrap>

           <div data-sly-resource="${ @path=item.number, resourceType='foundation/components/parsys'}"></div>




However, i'm not getting the list value on the page. The above approach has to be done using WCMUsePojo class in java.

Can anyone please provide their insight?


Bernadine Soman

Arun PatidarVeena_07smacdonald2008

3 Replies


Community Advisor

import java.util.ArrayList;

import java.util.List;

import javax.annotation.PostConstruct;

import javax.inject.Inject;





public class CustomColumnModel {

    @Inject @Optional

    protected String numberofcolumns;

    List<String> colList = new ArrayList<String>();


    protected void init() {

    if(!numberofcolumns.isEmpty()) {

    for(int i=0; i<Integer.parseInt(numberofcolumns);i++){





    public List<String> getColumns() {

        return colList;




<div data-sly-test="${wcmmode.edit}" class="col-content" style="color: gray;">Edit Column Container</br></div>

<div data-sly-use.colControl="com.acc.aem64.core.models.CustomColumnModel" data-sly-unwrap>

     <div class="sample-container">

         <div class="row class">

           <div data-sly-list="${colControl.columns}" data-sly-unwrap>

           <div data-sly-resource="${ @path=item, resourceType='foundation/components/parsys'}"></div>