Expand my Community achievements bar.

Touch UI - Read / Write Component Properties with Client Side Javascript

Avatar

Level 2

Hi,

I have a component and I would like to read and write some component properties. I was using "CQ.HTTP.post" in 5.61.

I'm wondering what is the best approach to do this.

Thanks

7 Replies

Avatar

Level 10

Assume that i have a component here: 

/apps/touchui-sightly-image-multifield/sample-image-multifield

As shown here: 

and i want to get properties of component sample-image-multifield such as sling:resourceSuperType

You can use QUeryBuilder API - see: 

https://docs.adobe.com/docs/en/aem/6-1/develop/search/querybuilder-api.html

Avatar

Level 10

Hi,

In general all properties/values will be stored in nodes as you will be aware

In order to access those properties/values we make ajax call, now you can either make those calls via method defined in jQuery library or you can use method defined in ExtJS framework.

Internally they will be making same calls to node for read and write.

and If you are making use of methods defined in ExtJS, I guess it should be fine.

This was based on my understanding....

Thanks

Praveen

Avatar

Level 2

Praveen, can provide a code sample?

There is no ExtJS in Touch UI, FYI.

Avatar

Level 10

Yup...agreed there is not ext js in touch ui,

in that case use something like

$.getJSON("/libs/wcm/core/resources/languages.2.json").done(function(data){ console.log(data); });

There is very good use for this, it was released today

http://adobeaemclub.com/touch-ui-dynamic-selection-of-multiple-drop-downs-in-aem-6-1/

Avatar

Level 10

Hi Bulent,

I think you can definitely use CQ.HTTP.Post to create a read and write component.

but in my opinion any operations should be done in the backend services while you can call that service from your frontend using JQuery 

 

Regards,

Lokesh

I 100% agree - its best practice with AEM to have a backend service read the JCR - not front end JS logic. Use front end JS logic to invoke a backend service and display the result set.