Expand my Community achievements bar.

SOLVED

dialog properties when used in Sling Model

Avatar

Community Advisor

Hi

 

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

Any thoughts?

1 Accepted Solution

Avatar

Correct answer by
Level 2

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.

View solution in original post

5 Replies

Avatar

Level 10

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;

Avatar

Community Advisor

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

Avatar

Level 5

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

Avatar

Community Advisor

@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 

Avatar

Correct answer by
Level 2

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.