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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

dialog properties when used in Sling Model

ManuMathew1994
Level 3
Level 3

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
VKumar2
Correct answer by
Level 2
Level 2

Hi @ManuMathew1994 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
kishorekumar14
Level 8
Level 8

Hi @ManuMathew1994 ,

 

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;

KiranVedantam1992
Community Advisor
Community Advisor

Hi @ManuMathew1994,

 

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

zeeshanKhan0786
Level 5
Level 5

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

ArunaSurukunta
Level 4
Level 4

@ManuMathew1994 ,

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 

VKumar2
Correct answer by
Level 2
Level 2

Hi @ManuMathew1994 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