Expand my Community achievements bar.

SOLVED

@Inject vs @Valuemap

Avatar

Level 5

Hi Team, 

Want to know what is the exact uses and differences of Inject & Valuemap. I can see in functionality vise both are doing the same thing. Can anyone explain why we need these annotations and what's the use of them. 

 

Thanks.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hello @Tessa_learner1 

 

@Inject is a general purpose annotation that makes the value available from a number of injectors.

 

@ValueMapValue is an injector specific annotation that will specifically pick value from valuemap injector. It is equivalent to @Inject @Source("valuemap")

 

When the injected value is available only from one injector, their behavior would be the same, however if the same property is provided by two different injectors (say script-binding and valuemap) they might inject different values.

 

Also, please refer to a similar thread https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/what-is-the-difference-bet... 


Aanchal Sikka

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hello @Tessa_learner1 

 

@Inject is a general purpose annotation that makes the value available from a number of injectors.

 

@ValueMapValue is an injector specific annotation that will specifically pick value from valuemap injector. It is equivalent to @Inject @Source("valuemap")

 

When the injected value is available only from one injector, their behavior would be the same, however if the same property is provided by two different injectors (say script-binding and valuemap) they might inject different values.

 

Also, please refer to a similar thread https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/what-is-the-difference-bet... 


Aanchal Sikka