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
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 ✌
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
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.
The selected property will not work if the value is already authored. Can you please check if you have authored it already? Also please let us know the resourceType you are using (Coral or Granite)
Views
Replies
Total Likes
1) Inplace editing is only for the the particular field(RTE), on submit only one particular field value will submitted. As the complete dialog form is not submitted you don't see other values.
2) Setting property seleted(boolean) true to option(not for first, I did set for n-1 option) , is working perfectly for me with both coral2 and coral3 select widgets.
AG
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Views
Replies
Total Likes
I would suggest don't set properties from support script or from any view script. Because it is presentation layer and suggested not to write any update/create logic with in a view. A simple solution for your use case is
use(function(){
properties.get("dropdownval", "5");
});
ValueMap has overloaded get method which will take default value as parameter. If the property is null. It will return the value that we provided.
AG
properties.get will return you the value if it is set , but the issue here is the value itself is not present in the node. I want to set that value, so that next time when the author opens the dialog , he will see that default values in the dropdowns properly. I know might be my use case is little confusing, but if you follow the steps I mentioned in the question, you will understand the issue correctly. And I don't think doing a little hack via server side JS won't be that bad
Views
Replies
Total Likes
you can simply set the default value for dropdown item using value property or using cq:template.
Please note, this will reflect the changes only for new edits existing authored component will not have any impact
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies