Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

OSGi properties value should not blank

Avatar

Level 2

Hi Team,

Please any body suggest me how to make OSGi property value should mandatory. Please find the below screenshot

1530708_pastedImage_0.png

Regards,

Jaganath

1 Accepted Solution

Avatar

Correct answer by
Level 10

Exactly - you are consuming these values in Java code. If in your Java code - the OSGi value is empty - set a default value in your code so your logic does not break. See this articel for more information - Reading OSGi Configuration Values for Adobe Experience Manager 6.3

View solution in original post

10 Replies

Avatar

Level 10

Do you mean for a custom service or general ones?

Avatar

Level 10

For general OSGi configurations - see - Configuring OSGi

However no mention of how to make any one field mandatory.

Avatar

Level 2

Thanks  Smacdonal,

Yes its custom OSGi services and also is it possible to make mandatory the sling:OsgiConfig property fields as below.

1530952_pastedImage_0.png

Avatar

Community Advisor

Dear Jaggu,

Not aware of such setting.

You are viewing it of slightly wrong angle. Normally, your OSGi config get's consumes in OSGi Service.

There you can take these parameters via Java method.

Such as @Activate or @Modified, there you can always make you validations for the user input.

In cases when config isEmpty or isInvalid, you don't have to add that config in. Instead, in OSGi you can define default value.

In case if I'm wrong you can verify implementation of felix/configadmin at trunk · apache/felix · GitHub where you would find the code that's running inside your configAdmin. *Update correct place to look at javascript felix/config.js at trunk · apache/felix · GitHub 

Alternatively, you can look at awesome writeup/talk by Jörg Sling Context-Aware configuration

With this sytem you can use Touch UI and can make any input pre-validated by standard AEM UI systems.

Hope this helps.

Regards,

Peter

Avatar

Level 2

Thanks for your response, you are correct Peter  but in OSGi we are using some key for lead submit. In case this property is blank then the whole system is breaking even though there is default value. So we need validation for not blank.

Regards,

Jaggu

Avatar

Community Advisor

Hi Jaggu,

That sounds like not very durable design if a single mis-config can break 'whole system'. Consider changing your OSGi code in a way that default value is always set. E.g. your Java code know's what the defaults are.

Regards,

Peter

Avatar

Correct answer by
Level 10

Exactly - you are consuming these values in Java code. If in your Java code - the OSGi value is empty - set a default value in your code so your logic does not break. See this articel for more information - Reading OSGi Configuration Values for Adobe Experience Manager 6.3

Avatar

Level 2

Thanks Peter, I need one more calcification can I give position to OSGi fields means in OSGi one field is coming on middle can I move this filed to top.