Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Dialog values not getting saved after updating dialog fields from the sling model

Avatar

Level 2

 

I am uploading the JSON. Based on this JSON other components fields are getting update. When I am opening the dialog values are coming from the uploaded JSON, which is correct . if I am changing dialogs value and saving the dialog , then again on the page values are coming from the JSON.

Requirement is dialog values should get update from the JSON and if user wants to change the dialog value , they can change as well. Both the cases should work.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@Anamika_13 :

if i understand this, you might be reading the JSON values and updating them at the page level . this logic you might have written at the sling model level. 

 

So sling model get invoked when ever you are opening the page or reloading the page . So if you manually added the value at page level , it will store the value.. but this will get override again by the logic you written in the sling model..

 

may be you can change the logic as , if the field is having the value already dont update from the JSON so that value you input manually will remain over there.

 

Thanks,

Siva

 

Thanks,
Siva

View solution in original post

4 Replies

Avatar

Community Advisor

Where are you reading JSON? Most probabily in Javascript of dialog right?

if you are using JS, you should put some condition in your js like if value are coming from back-end then don't assign the value from JS, if not then assign value from JS and JSON.

Meanwhile when you save your dialog after modification you can validate the saved value in CRX/de page path it should be modified value.

Hope this helps.

Umesh Thakur

Avatar

Level 2

For the JSON upload I have created separate component. From this JSON file , two components will get update. After uploading the JSON ,if author will update the dialog, node should get the update. I am not using the JS. I am modifying the JCR properties from the backend by reading the JSON file.

Avatar

Correct answer by
Community Advisor

@Anamika_13 :

if i understand this, you might be reading the JSON values and updating them at the page level . this logic you might have written at the sling model level. 

 

So sling model get invoked when ever you are opening the page or reloading the page . So if you manually added the value at page level , it will store the value.. but this will get override again by the logic you written in the sling model..

 

may be you can change the logic as , if the field is having the value already dont update from the JSON so that value you input manually will remain over there.

 

Thanks,

Siva

 

Thanks,
Siva

Avatar

Level 2

@SivakumarKanoori  yes you are correct. I have written the logic in sling model. I will change the logic to if the field is having the value already dont update from the JSON so that value you input manually will remain over there.