Default Value of Dropdown , not working when inplaceediting

Avatar

Avatar

Veena_Vikram

MVP

Avatar

Veena_Vikram

MVP

Veena_Vikram
MVP

10-11-2020

Hi All

 

    I have a component which has two tabs 

 

Tab 1 - RTE

Tab 2 - A dropdown with some values, let's say 1,2,3,4,5

 

  For me 5 is the default value which the author should see when he opens the dialog. So I have set selected=true on this value

 

Now I have inplaceediting enabled for the RTE. I have two issues which I need to solve

 

  1. When the author edits the dialog only via inplaceediting , the dropdown value is not set.
  2. After inplace editing , when I open the dialog using wrench icon , I see the dropdown value is 1 and not 5 ( which is not my default value but the first value in the order of values are added).

Am I missing something here ? Any help is appreciated 

 

edit :- the issue I am trying to tackle here is when author edits component via pencil (inplaceediting), basically he changes the text field alone, but when he open the dialog next time via wrench icon, he see that the dropdown is set to 1 instead of 5 (which as per him should not have changed unless he changed it ) . I understand that the defaultValue won't work when the component is authored already , but what I am trying to get a solution here is to either set the dropdown property to the backend when the user edits the component via pencil, so that when he opens the dialog next time , he see the default value

 

TIA 

Veena ✌

aem6.5 dropdown inplaceediting
View Entire Topic

Avatar

Avatar

Veena_Vikram

MVP

Avatar

Veena_Vikram

MVP

Veena_Vikram
MVP

11-11-2020

I think I figured out a solution. The issue what we are facing in this case was little weird than usual , as the business expectation was that way

 

  When the dialog has two tabs , and the user authors the dialog via inplace editing, only the RTE values are set in the node. Which means the node is already set , but the second tab values are not set. So when the user opens the dialog (via wrench icon) next time, he will not see the default value on dropdown as it will work only for the first time when the dialog is not authored. 

 

The possible solution I was looking at was to set this dropdown property ( lets call it as "dropdownval" ) at the same time the author edits the dialog via pencil icon ( In Place editing) . So what I did is I wrote a server side JS and wrote the below script in it 

 

use(function(){

 

 if(properties.get("dropdownval") == null){

      currentNode.setProperty("dropdownval","5");

      currentNode.getSession().save();
}

 

})

 

This will set the property "dropdownval" to the node, as soon the first time it is authored ( via InPlace or dialog)

 

PS: THIS IS JUST A HACK I FIGURED OUT.