Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!
SOLVED

baked in components

Avatar

Level 3

I have a component where its baked in and have mandatory fields.
when component is authored and later if  the components needs to be un authored  . It is not switching back to default state and displays previously authored content.

solutions I thought of
1.having a delete can  be an option (but it might drive into wrong direction for authors)

2. making fields not required ( it's against business rules ).

Any suggestions apart from what I have mentioned.  

1 Accepted Solution

Avatar

Correct answer by
Level 10

well this is happening because default post servlet is not triggered when validation for dialog fields return false(mandatory fields can't be empty). to over come this you have two options:\

1. create two tabs second tabs will be hidden, first tab will have a check box or radio button to enable or disable the component configuration, second tan will have your component dialog widgets.

one you enable the check box from tab one tab 2 will be enabled and you can configure this as per you requirement. when you don't need this component just select the disable option and this will trigger a listener which will delete the jcr content stored against tab 2 and disable to tab 2 which will allow you to submit the post servlet via default behavior.

2. Alternatively You can use a listeners, which will execute when dialog before submit. In that listener you can write js code to check if value is "" (empty) , the set the value to "N/A".

Help link: https://myprogressivelearning.wordpress.com/2015/01/21/setting-default-value-to-the-drop-down-of-dia...

Code will be similar to 

 
  1. function(dialog){
  2. x= dialog.findParentByType('dialog').getField('./vocLevel');
  3. if(x.getValue()=="")
  4. x.setValue("N/A");
  5. }

then Don't use NA value to display in your JSP or sightly; using NA will allow you to submit the value successfully.

 

Regards,

Amit

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

well this is happening because default post servlet is not triggered when validation for dialog fields return false(mandatory fields can't be empty). to over come this you have two options:\

1. create two tabs second tabs will be hidden, first tab will have a check box or radio button to enable or disable the component configuration, second tan will have your component dialog widgets.

one you enable the check box from tab one tab 2 will be enabled and you can configure this as per you requirement. when you don't need this component just select the disable option and this will trigger a listener which will delete the jcr content stored against tab 2 and disable to tab 2 which will allow you to submit the post servlet via default behavior.

2. Alternatively You can use a listeners, which will execute when dialog before submit. In that listener you can write js code to check if value is "" (empty) , the set the value to "N/A".

Help link: https://myprogressivelearning.wordpress.com/2015/01/21/setting-default-value-to-the-drop-down-of-dia...

Code will be similar to 

 
  1. function(dialog){
  2. x= dialog.findParentByType('dialog').getField('./vocLevel');
  3. if(x.getValue()=="")
  4. x.setValue("N/A");
  5. }

then Don't use NA value to display in your JSP or sightly; using NA will allow you to submit the value successfully.

 

Regards,

Amit

Avatar

Level 3

Hi Amit,

it worked for me what all you have suggested. Thanks a lot. 

Avatar

Level 3

i have one more question.
the same scenario applies for all templates except one were baked in component needs to be authored manually meaning the it will be not generated dynamically .

So when i try unauthor it is displaying N/A value(for the template where it is not dynamically generated).

 

need help here