Expand my Community achievements bar.

How to read a node value in dropdown listener event

Avatar

Level 3

Hi,

I have requirement to design a page with two controls 1. drop down list 2. Rich text box.

The rich text box value is dependent on selected drop down value. I.e Based on the drop down selected item, a node value (under content/mypage/jcr:content) to be read into the rich text box.

I understand from few sites that we can achive this through the 'listener' selectionchanged event. However I am struggling to read the node value and assign it to the rich text box.

Can anyone please guide me? or provide an example which meets my requirement.

Thank you in advance

Kishore

7 Replies

Thank you. This is very much helpful.

However I still need to understand how to get a node value (which is under content/mypage/jcr:content/mynode) through javascript.

For instance my dropdown has two values (value1 and value2) and if select value1 should read 'mynode' value and assign it to the text field.

Can you please help?

Avatar

Level 10

Is your dropdown in a component dialog like in the article.

Seems multifield may not be the best option for me. What I was looking for, have a single dropdown and rich text box in a dialog. The dropdown values are configurable as options for selection xtype. Based on the value selected in dropdown, a value to be read from a content node and populate in Rich text. This should also allow user to save the updated rich text content back to the relavent node.

Can you please help me on this?

Avatar

Administrator

Hi 

I am not sure, if this will help you.

But, there is something called "Custom Validation of Dialog" in AEM, you can create a custom validation for dialog fields. It just require CSS sector.

So using this concept, you can trigger some code. 

Link:- http://www.nateyolles.com/blog/2016/02/aem-touch-ui-custom-validation

So, here for selection you can trigger your piece of code. This code would be fetching the value from the dialog fields and sending or populating wherever you want.

 

I hope this would be of some help to you.

~kautuk



Kautuk Sahni

Avatar

Level 3

Hi,

Thank you for your response. 

Seems the example given is for touch UI but I am looking for classic UI support.

Can you please tell me, how to read a node under jcr:content from either javascript or jsp?

Thanks,

Kishore

Below snippet will gives you current node path Javascript  for the selection change event 
selectionchanged : function(el,val,check){
       var dialog = el.findParentByType('dialog');//gives dialog
       console.log(dialog .path);//gives current node path
       }
       

Hope this may help you for more details please refer link