dialog properties when used in Sling Model | Community
Skip to main content
Manu_Mathew_
New Participant
September 3, 2021
Solved

dialog properties when used in Sling Model

  • September 3, 2021
  • 5 replies
  • 2130 views

Hi

 

when we inject the properties in sling model using @586265 , is it compulsory for variable name used in sling model to be camel case? 

Any thoughts?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by VKumar2

Hi @manu_mathew_ No there is no camel case naming convention to follow while injecting the properties, however it is recommended to give the camel case for properties while creating the dialogs. 

However if you want to follow in your sling model, definitely you are having option @Named 

Hope it helps.

5 replies

VKumar2Accepted solution
New Participant
September 4, 2021

Hi @manu_mathew_ No there is no camel case naming convention to follow while injecting the properties, however it is recommended to give the camel case for properties while creating the dialogs. 

However if you want to follow in your sling model, definitely you are having option @Named 

Hope it helps.

Anny0505
New Participant
September 4, 2021

@manu_mathew_ ,

I don't think camelcase naming convention is necessary to follow to inject properties into sling models with @inject. However it is best practice to use camelcase notation for property values because AEM based on Java and Java uses camelcase notations to follow the guidelines in defining pojo classes and variables etc.

 

if you do not want to use camelcase notation for properties then you can use @named property to define your property 

zeeshanKhan0786
New Participant
September 3, 2021

@manu_mathew_  Its not necessary.If you are using @inject the property name in node and the in the sling model @inject tag is same.

Kiran_Vedantam
New Participant
September 3, 2021

Hi @manu_mathew_,

 

Camelcase is used in programming language to name different files and functions without violating the naming laws of the underlying language.

 

It is suggested as everyone follows it. You can still write your own attributes - but be aware of the issues you might face when you integrate with others code.

 

Thanks,

Kiran Vedantam

Kishore_Kumar_
New Participant
September 3, 2021

Hi @manu_mathew_ ,

 

It is basically a naming convention of java variables when we have more than one word.

 

and also camelCase convention is followed in AEM JCR properties as well. eg. firstName.

https://jackrabbit.apache.org/archive/wiki/JCR/NodeNamingConventions_115513460.html

 

but if you want a JCR property and sling model variables to be different we can use @Named annotations.
@Named("jcr:title")
private String title;