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

Alternative of deprecated SlingSettingsService

ibishika
Level 4
Level 4

Hi,

 

Does anyone know/has implemented something that helps you to fetch the runmode in backend code. SlingSettingsService has been deprecated

WCMMode doesn't work in this case as we need to check it on a editable template(structure), where wcmmode is disabled.

 

Thanks!

1 Accepted Solution
Dipti_Chauhan
Correct answer by
Community Advisor
Community Advisor

Hi

Till the time we have alternative of SlingSettingService you can set run mode config value with OSGI configuration and read this in you backend code.

 

Thanks

Dipti

View solution in original post

6 Replies
Dipti_Chauhan
Correct answer by
Community Advisor
Community Advisor

Hi

Till the time we have alternative of SlingSettingService you can set run mode config value with OSGI configuration and read this in you backend code.

 

Thanks

Dipti

View solution in original post

Jörg_Hoh
Employee
Employee

 

Your code should not reference any runmode (either directly or indirectly), instead it should get expressed via OSGI configuration. I wrote an article for it some time ago, which explains how you can/should do that: https://cqdump.joerghoh.de/2018/09/12/referencing-runmodes-in-java/

 

cheers,

Jörg

ibishika
Level 4
Level 4
@Jörg_Hoh, I did use OSGi configuration to implement the same and that worked as expected. My actual requirement was simple enough. I wanted to display some message on the component in edit mode. But edit mode is disabled in template structure. I never noticed something like this before and had an impression that any page having "editor.html" in URL is in edit mode. I would love to understand the reason behind why wcmmode is in disabled state in template structure. Do let me know if you know why is that so.
Jörg_Hoh
Employee
Employee
so you mean that when you create/modify an editable template, the wcmmode is not set properly?
ibishika
Level 4
Level 4
@Jörg_Hoh Yes that's right. When I fetch the wcmmodes on editable template the only mode that returns true is ${wcmmode.disabled}. ${wcmmode.edit} returns false.