Expand my Community achievements bar.

SOLVED

Alternative of deprecated SlingSettingsService

Avatar

Level 6

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

Avatar

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

7 Replies

Avatar

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

Avatar

Community Advisor

Hi @Dipti_Chauhan ,

 

Do you have any examples, which we can refer as I have also same requirement and we need to use an alternative?
Thanks!

Avatar

Employee Advisor

 

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

Avatar

Level 6
@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.

Avatar

Employee Advisor
so you mean that when you create/modify an editable template, the wcmmode is not set properly?

Avatar

Level 6
@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.