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?
Solved! Go to Solution.
Views
Replies
Total Likes
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.
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;
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
@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.
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
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.
Views
Likes
Replies
Views
Likes
Replies