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
BedrockMission!

Learn More

View all

Sign in to view all badges

Access Inner Class Variables In Sightly

Avatar

Avatar
Validate 25
Level 3
vdhim23
Level 3

Like

1 like

Total Posts

135 posts

Correct Reply

9 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile

Avatar
Validate 25
Level 3
vdhim23
Level 3

Like

1 like

Total Posts

135 posts

Correct Reply

9 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile
vdhim23
Level 3

20-04-2019

Hi,

I am trying to access inner class properties using data-sly-list as below but it shows me there are 3 objects but not sure how to print the values of objects. I tried with . operator but nothing is visible.

<sly data-sly-test="${tabContentItems.showFilters}">
  <ul class="nav nav-tabs" role="tablist">
  <sly data-sly-list.nav="${tabContentItems.filterNav}">
  # ${nav.filterName}
  </sly>
  </ul>
</sly>

Snippet of sling model :

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

// Populating CTA

  private class CTA {
  private String filterName;
  private String filterImage;


  public String getFilterName() {
  return filterName;
  }

  public void setFilterName(String filterName) {
  this.filterName = filterName;
  }

  public String getFilterImage() {
  return filterImage;
  }

  public void setFilterImage(String filterImage) {
  this.filterImage = filterImage;
  }

  public CTA(String filterName, String filterImage) {
  this.filterName = filterName;
  this.filterImage = filterImage;
  }
  }
}

Thanks,

Replies

Avatar

Avatar
Validate 10
Level 2
Venkatesha_Gamp
Level 2

Likes

3 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Give Back 3
Give Back
Boost 3
View profile

Avatar
Validate 10
Level 2
Venkatesha_Gamp
Level 2

Likes

3 likes

Total Posts

40 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Give Back 3
Give Back
Boost 3
View profile
Venkatesha_Gamp
Level 2

20-04-2019

May i know what is the requirement?

Why are you using inner class?

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

20-04-2019

If you setup your sling model class properly - there should be no reason to attempt to access an inner class. You should be able to get the data, including collections as shown here - in the Sling Model section: Building Experience Manager Components using Granite/Coral Resource Types

Avatar

Avatar
Validate 25
Level 3
vdhim23
Level 3

Like

1 like

Total Posts

135 posts

Correct Reply

9 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile

Avatar
Validate 25
Level 3
vdhim23
Level 3

Like

1 like

Total Posts

135 posts

Correct Reply

9 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile
vdhim23
Level 3

20-04-2019

Hi,

I can achieve my use-case in other way also but curious to know whether we can access inner class variables via object of outer class in sightly.

Avatar

Avatar
Validate 25
Level 3
vdhim23
Level 3

Like

1 like

Total Posts

135 posts

Correct Reply

9 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile

Avatar
Validate 25
Level 3
vdhim23
Level 3

Like

1 like

Total Posts

135 posts

Correct Reply

9 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile
vdhim23
Level 3

20-04-2019

Issue solved, changed the access specifier of inner class.