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

SOLVED

Accessing Dialog Properties in WCMUsePojo - getProperties() vs get()

Tyler_Maynard
Level 4
Level 4

I have a component embbedded onto a page using the following HTL markup:

<div data-sly-resource="${'myResource' @ resourceType='path/to/my/resource'}"></div>

In my component's  HTL I am using the java-use to access a local Java Class for logic:

<sly data-sly-use.articleSlider="ArticleSlider"></sly>

Within my Java class, I am accessing component dialog properties which are added by an author, but for some reason I can't simply use the get("propertyName", "String.class"). Trying to understand why I can't do that, but i can access it when using getProperties() method:

@Override public void activate() throws Exception { String featureByGetProperties = getProperties().get("featureone", ""); // <- THIS WORKS String featureByGet = get("featureone", String.class); // <- THIS IS NULL }

Everything I read (including the AEM Documentation) tells me that simply using the get() method should grab the property from the resource. Just trying to understand why one works and not the other.

1 Accepted Solution
Feike_Visser1
Correct answer by
Employee
Employee

get() can be used when you pass in for example a parameter.

For the use-cases to get a property you need to access it via getProperties().

Where have you seen that in the documentation?

View solution in original post

1 Reply
Feike_Visser1
Correct answer by
Employee
Employee

get() can be used when you pass in for example a parameter.

For the use-cases to get a property you need to access it via getProperties().

Where have you seen that in the documentation?

View solution in original post