@Inject vs @Valuemap | Community
Skip to main content
Level 4
July 4, 2023
Solved

@Inject vs @Valuemap

  • July 4, 2023
  • 1 reply
  • 583 views

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.

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 aanchal-sikka

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-between-inject-and-valuemapvalue-in/m-p/540055/highlight/true 

1 reply

aanchal-sikka
Community Advisor
aanchal-sikkaCommunity AdvisorAccepted solution
Community Advisor
July 4, 2023

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-between-inject-and-valuemapvalue-in/m-p/540055/highlight/true 

Aanchal Sikka