Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

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

Avatar

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

Avatar

Correct answer by
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

Avatar

Correct answer by
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?