Best Approach for this scenario

Avatar

Avatar
Validate 1
Level 1
AEMnewbie
Level 1

Likes

0 likes

Total Posts

88 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
AEMnewbie
Level 1

Likes

0 likes

Total Posts

88 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Applaud 5
View profile
AEMnewbie
Level 1

22-08-2020

I have an image and video dropdown based on which the following field for video or image link is displayed.. I have a requirement to save the value from the selected field to a single property in jcr.

 

i.e If the video was selected the link property should be video link and the next time when the image is selected the link should be updated to image link. 

I have a sling model using which this data is exposed as json and final json should have only one value for the link (image or video) . 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 250
MVP
Nikhil-Kumar
MVP

Likes

251 likes

Total Posts

262 posts

Correct reply

38 solutions
Top badges earned
Boost 250
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile

Avatar
Boost 250
MVP
Nikhil-Kumar
MVP

Likes

251 likes

Total Posts

262 posts

Correct reply

38 solutions
Top badges earned
Boost 250
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile
Nikhil-Kumar
MVP

23-08-2020

@AEMnewbie 
First of all if you have two different fields in that case there can't be single property in JCR for both.

I would have done the following thing if I ever got this requirement to implement:
Approach 1:
1. I will get the value selected in Dropdown in sling model. (let's suppose I get seletedValues as image)
2. Based on the value that I get in step 1 I will add that link as part of JSON and Ignore the other one, In this case I will ass the imageUrl as part of JSON.
Same applies for the Video as well.

Approach 2:
Lets suppose you have a single Link field for image and video. In that case save the value with single prop name i.e link.
Then based on the dropdown value update the key value to imagLink or videoLink in JSON taking the value as the link.


Thanks,
Nikhil

Answers (0)